summaryrefslogtreecommitdiff
path: root/sbin/sysctl
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2019-02-21 16:37:14 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2019-02-21 16:37:14 +0000
commit02d49193dbccbe0504a98b6c516b3f6f8cd4a826 (patch)
tree21eae3fdf007c16636bf82115141c24c33e27e71 /sbin/sysctl
parentb38ed8bcf85e717359ab24533af5807a918e79c7 (diff)
If sysctl(8) was compiled with an obsolete struct sensordev size,
it could get stuck in an endless loop. After sensors sysctl(2) fails, do not continue using uninitialized memory. Catch the error, print a warning, and skip the sensors. OK benno@ visa@ deraadt@
Diffstat (limited to 'sbin/sysctl')
-rw-r--r--sbin/sysctl/sysctl.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index cd2be30f80e..71e06f0064e 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.c,v 1.240 2019/01/29 14:07:15 visa Exp $ */
+/* $OpenBSD: sysctl.c,v 1.241 2019/02/21 16:37:13 bluhm Exp $ */
/* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */
/*
@@ -2418,6 +2418,8 @@ sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep)
continue;
if (errno == ENOENT)
break;
+ warn("sensors dev %d", dev);
+ return (-1);
}
snprintf(buf, sizeof(buf), "%s.%s",
string, snsrdev.xname);
@@ -2443,6 +2445,8 @@ sysctl_sensors(char *string, char **bufpp, int mib[], int flags, int *typep)
continue;
if (errno == ENOENT)
break;
+ warn("sensors dev %d", dev);
+ return (-1);
}
if (strcmp(devname, snsrdev.xname) == 0)
break;