mirror of
https://github.com/troglobit/finit.git
synced 2026-10-21 11:29:42 +00:00
pidfile_read(): Fix potential integer overflow when reading PID
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
5ff7994852
commit
a296c2dd00
1 file changed
+1
-1
@@ -149,7 +149,7 @@ pid_t pidfile_read(char *pidfile)
|
|||||||
|
|
||||||
if (fgets(buf, sizeof(buf), fp)) {
|
if (fgets(buf, sizeof(buf), fp)) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
pid = strtoul(buf, NULL, 0);
|
pid = (pid_t)strtol(buf, NULL, 10);
|
||||||
if (errno)
|
if (errno)
|
||||||
pid = 0; /* Failed conversion. */
|
pid = 0; /* Failed conversion. */
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user