From: Hauke Mehrtens Date: Thu, 31 Mar 2022 16:43:09 +0000 (+0200) Subject: busybox: Fix snprintf arguments in lock X-Git-Tag: v22.03.0-rc1~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d18e365b17d1c247cffcc1686d66c88b74d3446c;p=thirdparty%2Fopenwrt.git busybox: Fix snprintf arguments in lock The first argument for snprintf is the buffer and the 2. one is the size. Fix the order. This broke the lock application. Fixes: 9d2b26d5a705 ("busybox: fix busybox lock applet pidstr buffer overflow") Reported-by: Hartmut Birr Signed-off-by: Hauke Mehrtens (cherry picked from commit d80336e1a970b088c235dcf2773052537e6f5d72) --- diff --git a/package/utils/busybox/patches/220-add_lock_util.patch b/package/utils/busybox/patches/220-add_lock_util.patch index 623121b9fb9..579b705f346 100644 --- 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); -+ snprintf(sizeof(pidstr), pidstr, "%d\n", pid); ++ snprintf(pidstr, sizeof(pidstr), "%d\n", pid); + write(fd, pidstr, strlen(pidstr)); + close(fd); + }