Sanity check the list obtained from the kern.disks sysctl so that Disk_Names()
doesn't get fooled into returning a bogus list. This should fix sysinstall from segfaulting when no disk devices are present.
This commit is contained in:
parent
f9b96756eb
commit
4e89f2d88f
@ -470,6 +470,9 @@ Disk_Names()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (listsize == 0)
|
||||
return (NULL);
|
||||
|
||||
disks = malloc(sizeof *disks * (1 + MAX_NO_DISKS));
|
||||
if (disks == NULL)
|
||||
return NULL;
|
||||
@ -481,7 +484,7 @@ Disk_Names()
|
||||
memset(disks,0,sizeof *disks * (1 + MAX_NO_DISKS));
|
||||
memset(disklist, 0, listsize + 1);
|
||||
error = sysctlbyname("kern.disks", disklist, &listsize, NULL, 0);
|
||||
if (error) {
|
||||
if (error || disklist[0] == 0) {
|
||||
free(disklist);
|
||||
free(disks);
|
||||
return NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user