busybox: Fix snprintf arguments in lock
authorHauke Mehrtens <hauke@hauke-m.de>
Thu, 31 Mar 2022 16:43:09 +0000 (18:43 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Thu, 31 Mar 2022 16:46:53 +0000 (18:46 +0200)
The first argument for snprintf is the buffer and the 2. one is the
size. Fix the order. This broke the lock application.

Fixes: 34567750db2c ("busybox: fix busybox lock applet pidstr buffer overflow")
Reported-by: Hartmut Birr <e9hack@gmail.com>
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
package/utils/busybox/patches/220-add_lock_util.patch

index 623121b9fb9fd1913230424b217cc648a5fe32d2..579b705f346451534c6fb6ffe14da9df54a481c3 100644 (file)
 +              if (!waitonly) {
 +                      lseek(fd, 0, SEEK_SET);
 +                      ftruncate(fd, 0);
-+                      snprintf(sizeof(pidstr), pidstr, "%d\n", pid);
++                      snprintf(pidstr, sizeof(pidstr), "%d\n", pid);
 +                      write(fd, pidstr, strlen(pidstr));
 +                      close(fd);
 +              }