Fwd: [PATCH] pidfiles: check if arg, path is empty string

Leesoo Ahn yisooan at fedoraproject.org
Wed Apr 15 05:12:35 UTC 2020


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 <yisooan at fedoraproject.org>
받는 사람: busybox at busybox.net
참조: Leesoo Ahn <yisooan at fedoraproject.org>

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 <yisooan at fedoraproject.org>
---
  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



More information about the busybox mailing list