bug in busybox lock

e9hack e9hack at gmail.com
Thu Mar 31 07:11:23 PDT 2022


Hi,

commit

busybox: fix busybox lock applet pidstr buffer overflow

looks wrong for me:

--- a/package/utils/busybox/patches/220-add_lock_util.patch
+++ b/package/utils/busybox/patches/220-add_lock_util.patch
@@ -109,7 +109,7 @@
  +              if (!waitonly) {
  +                      lseek(fd, 0, SEEK_SET);
  +                      ftruncate(fd, 0);
-+                      sprintf(pidstr, "%d\n", pid);
++                      snprintf(sizeof(pidstr), pidstr, "%d\n", pid);
  +                      write(fd, pidstr, strlen(pidstr));
  +                      close(fd);
  +              }

The first parameter in snprintf() must be the buffer and the second the length.

Regards,
Hartmut



More information about the openwrt-devel mailing list