summaryrefslogtreecommitdiff
path: root/src/filelock.c
diff options
context:
space:
mode:
authorRobert Pluim <rpluim@gmail.com>2019-06-19 08:52:50 +0200
committerRobert Pluim <rpluim@gmail.com>2019-06-20 10:42:21 +0200
commit04477adedcee0d023dabc46a652f1673a2e9bd95 (patch)
treec9b6e47ff3b16ac1f2076fd1d0d41ebe5e594198 /src/filelock.c
parent81535eeadb5b9b964dd195b2720de2b1fc432c6e (diff)
downloademacs-04477adedcee0d023dabc46a652f1673a2e9bd95.tar.gz
Check that length of data returned by sysctl is non-zero
The length of the data returned by sysctl can be zero, which was not checked for. This could cause crashes, e.g. when querying non-existent processes. (Bug#36279) * src/sysdep.c (list_system_processes) [DARWIN_OS || __FreeBSD__]: (system_process_attributes) [__FreeBSD__]: (system_process_attributes) [DARWIN_OS]: * src/filelock.c (get_boot_time) [CTL_KERN && KERN_BOOTTIME]: Check for zero length data returned by sysctl.
Diffstat (limited to 'src/filelock.c')
-rw-r--r--src/filelock.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/filelock.c b/src/filelock.c
index 81d98f36fa4..bcd5bff563d 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -152,7 +152,7 @@ get_boot_time (void)
mib[1] = KERN_BOOTTIME;
size = sizeof (boottime_val);
- if (sysctl (mib, 2, &boottime_val, &size, NULL, 0) >= 0)
+ if (sysctl (mib, 2, &boottime_val, &size, NULL, 0) >= 0 && size != 0)
{
boot_time = boottime_val.tv_sec;
return boot_time;