On Tuesday 2015-11-17 22:20, David Miller wrote:
>> +    static char path_buf[PATH_MAX]; /* protected by kernfs_mutex */
>> +    int len = strlen(path);
> ...
>> +    if (len >= PATH_MAX)
>> +            return NULL;
>> +
>> +    memcpy(path_buf, path, len + 1);
>
>       static char path_buf[PATH_MAX]; /* protected by kernfs_mutex */
>       int len = strlcpy(path_buf, path, PATH_MAX);
> ...
>       if (len >= PATH_MAX)
>               return NULL;

        if (len < 0 || len >= PATH_MAX)

strlcpy returns a size_t, which, when coerced into an int, could lead to
negative numbers. In that sense, "size_t len" probably seems like an even
better bet yet.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to