Project

General

Profile

Actions

Bug #6169

open

libfakekernel: Unexpected ENAMETOOLONG from copystr()

Added by Marcel Telka almost 7 years ago. Updated almost 7 years ago.

Status:
New
Priority:
Low
Category:
lib - userland libraries
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.

Actions

Also available in: Atom PDF