Message ID | 20210222151231.22572-16-romain.perier@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Manual replacement of all strlcpy in favor of strscpy | expand |
On Mon, 22 Feb 2021 16:12:26 +0100, Romain Perier wrote: > > The strlcpy() reads the entire source buffer first, it is dangerous if > the source buffer lenght is unbounded or possibility non NULL-terminated. > It can lead to linear read overflows, crashes, etc... > > As recommended in the deprecated interfaces [1], it should be replaced > by strscpy. > > This commit replaces all calls to strlcpy that handle the return values > by the corresponding strscpy calls with new handling of the return > values (as it is quite different between the two functions). > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy > > Signed-off-by: Romain Perier <romain.perier@gmail.com> The strlcpy() usage in sound/* have been already converted on the latest Linus tree. So please drop this one. thanks, Takashi
diff --git a/sound/usb/card.c b/sound/usb/card.c index 85ed8507e41a..acb1ea3e16a3 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -496,7 +496,7 @@ static void usb_audio_make_longname(struct usb_device *dev, struct snd_card *card = chip->card; const struct usb_audio_device_name *preset; const char *s = NULL; - int len; + ssize_t len; preset = lookup_device_name(chip->usb_id);
The strlcpy() reads the entire source buffer first, it is dangerous if the source buffer lenght is unbounded or possibility non NULL-terminated. It can lead to linear read overflows, crashes, etc... As recommended in the deprecated interfaces [1], it should be replaced by strscpy. This commit replaces all calls to strlcpy that handle the return values by the corresponding strscpy calls with new handling of the return values (as it is quite different between the two functions). [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy Signed-off-by: Romain Perier <romain.perier@gmail.com> --- sound/usb/card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)