Revert "busybox: fix busybox lock applet pidstr buffer overflow (#9163)"

This reverts commit e9c3781bb9.
This commit is contained in:
lean 2022-04-01 10:19:02 +08:00
parent 624a9f9703
commit d17bbf492d

View File

@ -72,9 +72,9 @@
+ +
+static int do_lock(void) +static int do_lock(void)
+{ +{
+ pid_t pid; + int pid;
+ int flags; + int flags;
+ char pidstr[12]; + char pidstr[8];
+ +
+ if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0700)) < 0) { + if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0700)) < 0) {
+ if ((fd = open(file, O_RDWR)) < 0) { + if ((fd = open(file, O_RDWR)) < 0) {
@ -109,7 +109,7 @@
+ if (!waitonly) { + if (!waitonly) {
+ lseek(fd, 0, SEEK_SET); + lseek(fd, 0, SEEK_SET);
+ ftruncate(fd, 0); + ftruncate(fd, 0);
+ snprintf(sizeof(pidstr), pidstr, "%d\n", pid); + sprintf(pidstr, "%d\n", pid);
+ write(fd, pidstr, strlen(pidstr)); + write(fd, pidstr, strlen(pidstr));
+ close(fd); + close(fd);
+ } + }