Actions
Bug #6169
openlibfakekernel: Unexpected ENAMETOOLONG from copystr()
Start date:
2015-08-28
Due date:
% Done:
0%
Estimated time:
Difficulty:
Bite-size
Tags:
needs-triage
Gerrit CR:
Description
It looks like that in a case the length of the source (src) string is max_len-1 the copystr() in libfakekernel will fail and return ENAMETOOLONG.
28int 29copystr(const char *src, char *dst, size_t max_len, size_t *outlen) 30{ 31 size_t copied; 32 33 if (max_len == 0) 34 return (ENAMETOOLONG); 35 36 copied = strlcpy(dst, src, max_len) + 1; 37 if (copied >= max_len) 38 return (ENAMETOOLONG); 39 40 if (outlen != NULL) 41 *outlen = copied; 42 43 return (0); 44}
The condition at line 37 should be changed to "greater than" so the string is properly copied.
Note: The special case handling at lines 33 and 34 could be removed since this case should be properly handled by the rest of the function.
Updated by Gordon Ross almost 7 years ago
OK, just please make sure this function retains the same interface and semantics (as much as possible) as the other copystr() functions implemented in the kernel.
Actually, hold on. Notes on developer indicate this already has the semantics we want. Is there a reproducible bug here?
Actions