Message ID | 20210222151231.22572-1-romain.perier@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | Manual replacement of all strlcpy in favor of strscpy | expand |
On 2/22/21 8:12 AM, Romain Perier wrote: > strlcpy() copy a C-String into a sized buffer, the result is always a > valid NULL-terminated that fits in the buffer, howerver it has severals > issues. It reads the source buffer first, which is dangerous if it is non > NULL-terminated or if the corresponding buffer is unbounded. Its safe > replacement is strscpy(), as suggested in the deprecated interface [1]. > > We plan to make this contribution in two steps: > - Firsly all cases of strlcpy's return value are manually replaced by the > corresponding calls of strscpy() with the new handling of the return > value (as the return code is different in case of error). > - Then all other cases are automatically replaced by using coccinelle. > Cool. A quick check shows me 1031 strscpy() calls with no return checks. All or some of these probably need to be reviewed and add return checks. Is this something that is in the plan to address as part of this work? thanks, -- Shuah
Le lun. 22 févr. 2021 à 17:36, Shuah Khan <skhan@linuxfoundation.org> a écrit : > > Cool. A quick check shows me 1031 strscpy() calls with no return > checks. All or some of these probably need to be reviewed and add > return checks. Is this something that is in the plan to address as > part of this work? > > thanks, > -- Shuah > Hi, Initially, what we planned with Kees is to firstly replace all calls with error handling codes (like this series does), and then replace all other simple calls (without error handling). However, we can also start a discussion about this topic, all suggestions are welcome. I am not sure that it does make sense to check all returns code in all cases (for example in arch/alpha/kernel/setup.c, there are a ton of other examples in the kernel). But a general review (as you suggest), would make sense. Regards, Romain