Its title is wrong... I'll post new fixed patch soon.

Leesoo


-------- 전달된 메시지 --------
제목: [PATCH] pidfiles: check if arg, path is empty string
날짜: Wed, 15 Apr 2020 14:03:42 +0900
보낸 사람: Leesoo Ahn <[email protected]>
받는 사람: [email protected]
참조: Leesoo Ahn <[email protected]>

Although open() syscall returns -1 with an empty string and
is like error handling behavior, checking if the arg is empty
string at the early stage is much better. Hence, we do not
need to pay the overhead of calling the syscall at all.

Signed-off-by: Leesoo Ahn <[email protected]>
---
 libbb/pidfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libbb/pidfile.c b/libbb/pidfile.c
index a6a282562..51432133d 100644
--- a/libbb/pidfile.c
+++ b/libbb/pidfile.c
@@ -20,7 +20,7 @@ void FAST_FUNC write_pidfile(const char *path)
        char buf[sizeof(int)*3 + 2];
        struct stat sb;
 -      if (!path)
+       if (!path || *path == '\0')
                return;
        /* we will overwrite stale pidfile */
        pid_fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666);
--
2.24.1

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to