From f9e425b336a2f19dd0e4bb8493f67048aa16ac89 Mon Sep 17 00:00:00 2001 From: Giorgos Keramidas Date: Thu, 10 Oct 2002 10:07:19 +0000 Subject: [PATCH] Make sure strsep() gets a nul-terminated string. Reviewed by: phk --- sbin/mdconfig/mdconfig.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index a1c125ec28b9..c77700079e28 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -211,8 +211,9 @@ list(const int fd) if (sysctlbyname("kern.disks", NULL, &dll, NULL, 0) == -1) err(1, "sysctlbyname: kern.disks"); - if ( (disklist = malloc(dll)) == NULL) + if ( (disklist = malloc(dll + 1)) == NULL) err(1, "malloc"); + bzero(disklist, dll + 1); if (sysctlbyname("kern.disks", disklist, &dll, NULL, 0) == -1) err(1, "sysctlbyname: kern.disks");