From b990a071b364696432de23a7b6f84807156129fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gomez?= Date: Sun, 9 Jan 2022 20:11:01 +0100 Subject: [PATCH] sanitize: fix pid/pidfile handling --- src/bip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/bip.c b/src/bip.c index f975031..1871aed 100644 --- a/src/bip.c +++ b/src/bip.c @@ -179,7 +179,7 @@ try_again: fatal("%s %s", "gethostname", strerror(errno)); hname[511] = 0; snprintf(longpath, longpath_max - 1, "%s.%s.%ld", conf_pid_file, hname, - (long unsigned int)getpid()); + (long)getpid()); longpath[longpath_max] = 0; if ((fd = open(longpath, O_CREAT|O_WRONLY, S_IWUSR|S_IRUSR)) == -1) fatal("Cannot write to PID file (%s) %s", longpath, @@ -199,13 +199,13 @@ try_again: pid_is_there: { pid_t pid; - long unsigned int p; + size_t p; if (fd != -1) close(fd); if (f) { - int c = fscanf(f, "%ld", &p); + int c = fscanf(f, "%zu", (size_t *)&p); fclose(f); - pid = p; + pid = (pid_t)p; if (c != 1 || p == 0) { mylog(LOG_INFO, "pid file found but invalid " "data inside. Continuing...\n");