[smartmontools-support] memory corruption problem on NetBSD
Alexander Nasonov
alnsn at yandex.ru
Mon Jun 10 22:08:45 CEST 2019
netbsd_smart_interface::get_dev_names() doesn't return a failure
early when no devices match a prefix (n == 0) and leads to a memory
corruption later. The patch below fixes this problem.
--
Alex
--- os_netbsd.cpp.orig 2018-09-16 15:03:22.000000000 +0000
+++ os_netbsd.cpp
@@ -603,6 +603,9 @@ int netbsd_smart_interface::get_dev_name
n++;
}
+ if (n == 0)
+ return -1;
+
char ** tmp = (char **)realloc(mp, n * (sizeof(char *)));
if (NULL == tmp) {
pout("Out of memory constructing scan device list\n");
More information about the Smartmontools-support
mailing list