Enhancement #750 » 0013-sanitize-fix-pid-pidfile-handling.patch
src/bip.c | ||
---|---|---|
178 | 178 |
fatal("%s %s", "gethostname", strerror(errno)); |
179 | 179 |
hname[511] = 0; |
180 | 180 |
snprintf(longpath, longpath_max - 1, "%s.%s.%ld", conf_pid_file, hname, |
181 |
(long unsigned int)getpid());
|
|
181 |
(long)getpid()); |
|
182 | 182 |
longpath[longpath_max] = 0; |
183 | 183 |
if ((fd = open(longpath, O_CREAT|O_WRONLY, S_IWUSR|S_IRUSR)) == -1) |
184 | 184 |
fatal("Cannot write to PID file (%s) %s", longpath, |
... | ... | |
198 | 198 |
pid_is_there: |
199 | 199 |
{ |
200 | 200 |
pid_t pid; |
201 |
long unsigned int p;
|
|
201 |
size_t p;
|
|
202 | 202 |
if (fd != -1) |
203 | 203 |
close(fd); |
204 | 204 |
if (f) { |
205 |
int c = fscanf(f, "%ld", &p);
|
|
205 |
int c = fscanf(f, "%zu", (size_t *)&p);
|
|
206 | 206 |
fclose(f); |
207 |
pid = p; |
|
207 |
pid = (pid_t)p;
|
|
208 | 208 |
if (c != 1 || p == 0) { |
209 | 209 |
mylog(LOG_INFO, "pid file found but invalid " |
210 | 210 |
"data inside. Continuing...\n"); |
211 |
- |