check sysctl error return on both calls.
this prevents sysctl from coredumping if the second call fails while the first succeeds. This isn't supposed to happen, but there is another bug in the i386 kernel implementation of sysctl machdep.diskinfo that excites this
This commit is contained in:
parent
e6e2e32ac1
commit
3aca86e05b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fdisk.c,v 1.80 2004/05/19 07:36:14 dyoung Exp $ */
|
||||
/* $NetBSD: fdisk.c,v 1.81 2004/07/30 23:42:29 dbj Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
@ -35,7 +35,7 @@
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fdisk.c,v 1.80 2004/05/19 07:36:14 dyoung Exp $");
|
||||
__RCSID("$NetBSD: fdisk.c,v 1.81 2004/07/30 23:42:29 dbj Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -1012,11 +1012,14 @@ get_geometry(void)
|
||||
mib[0] = CTL_MACHDEP;
|
||||
mib[1] = CPU_DISKINFO;
|
||||
if (sysctl(mib, 2, NULL, &len, NULL, 0) < 0) {
|
||||
intuit_translated_geometry();
|
||||
return;
|
||||
goto out;
|
||||
}
|
||||
dl = (struct disklist *) malloc(len);
|
||||
sysctl(mib, 2, dl, &len, NULL, 0);
|
||||
if (sysctl(mib, 2, dl, &len, NULL, 0) < 0) {
|
||||
free(dl);
|
||||
dl = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
get_diskname(disk, diskname, sizeof diskname);
|
||||
|
||||
@ -1040,6 +1043,7 @@ get_geometry(void)
|
||||
return;
|
||||
}
|
||||
}
|
||||
out:
|
||||
/* Allright, allright, make a stupid guess.. */
|
||||
intuit_translated_geometry();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user