Project

General

Profile

Enhancement #750 » 0013-sanitize-fix-pid-pidfile-handling.patch

Loïc Gomez, 2022-01-10 19:28

View differences:

src/bip.c
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,
......
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");
(12-12/24)