Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging/vc04_services: Remove all strcpy() uses in favor of strscpy()

strcpy() performs no bounds checking on the destination buffer. This
could result in linear overflows beyond the end of the buffer, leading
to all kinds of misbehaviors. The safe replacement is strscpy().

Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20210718131217.3806-1-len.baker@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Len Baker and committed by
Greg Kroah-Hartman
7aaabc37 041878d4

+2 -2
+1 -1
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
··· 884 884 885 885 vchiq_mmal_version(dev->instance, &major, &minor); 886 886 887 - strcpy((char *)cap->driver, "bm2835 mmal"); 887 + strscpy(cap->driver, "bm2835 mmal", sizeof(cap->driver)); 888 888 snprintf((char *)cap->card, sizeof(cap->card), "mmal service %d.%d", 889 889 major, minor); 890 890
+1 -1
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
··· 3716 3716 sizeof(remoteport) - len2, 3717 3717 " (client %x)", service->client_id); 3718 3718 } else { 3719 - strcpy(remoteport, "n/a"); 3719 + strscpy(remoteport, "n/a", sizeof(remoteport)); 3720 3720 } 3721 3721 3722 3722 len += scnprintf(buf + len, sizeof(buf) - len,