Correct a bug which could cause a segfault if there is no uc_devlist

data.

Noticed by:	Bill Swingle <bill@cdrom.com>
This commit is contained in:
Jordan K. Hubbard 1999-05-12 23:08:02 +00:00
parent a89c3bd3dc
commit 61bdb7bc9b
2 changed files with 22 additions and 20 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: kget.c,v 1.7 1999/05/06 11:03:17 jkh Exp $
* $Id: kget.c,v 1.8 1999/05/07 04:36:20 jkh Exp $
*/
#include "sysinstall.h"
@ -44,12 +44,20 @@ kget(char *out)
struct pnp_cinfo *c;
char *p;
/* create the output file; if we end up not writing to it, we'll
unlink() it later. */
fout = fopen(out, "w");
if (fout == NULL) {
msgDebug("kget: Unable to open %s for writing.\n", out);
return -1;
}
/* We use sysctlbyname, because the oid is unknown (OID_AUTO) */
/* get the buffer size */
i = sysctlbyname(mib1, NULL, &len, NULL, NULL);
if (i) {
msgDebug("kget: error buffer sizing\n");
return -1;
goto pnp;
}
if (len <= 0) {
msgDebug("kget: mib1 has length of %d\n", len);
@ -59,16 +67,9 @@ kget(char *out)
i = sysctlbyname(mib1, buf, &len, NULL, NULL);
if (i) {
msgDebug("kget: error retrieving data\n");
return -1;
goto pnp;
}
/* now it's time to create the output file; if we end up not writing to
it, we'll unlink() it later. */
fout = fopen(out, "w");
if (fout == NULL) {
msgDebug("kget: Unable to open %s for writing.\n", out);
return -1;
}
i = 0;
while (i < len) {

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: kget.c,v 1.7 1999/05/06 11:03:17 jkh Exp $
* $Id: kget.c,v 1.8 1999/05/07 04:36:20 jkh Exp $
*/
#include "sysinstall.h"
@ -44,12 +44,20 @@ kget(char *out)
struct pnp_cinfo *c;
char *p;
/* create the output file; if we end up not writing to it, we'll
unlink() it later. */
fout = fopen(out, "w");
if (fout == NULL) {
msgDebug("kget: Unable to open %s for writing.\n", out);
return -1;
}
/* We use sysctlbyname, because the oid is unknown (OID_AUTO) */
/* get the buffer size */
i = sysctlbyname(mib1, NULL, &len, NULL, NULL);
if (i) {
msgDebug("kget: error buffer sizing\n");
return -1;
goto pnp;
}
if (len <= 0) {
msgDebug("kget: mib1 has length of %d\n", len);
@ -59,16 +67,9 @@ kget(char *out)
i = sysctlbyname(mib1, buf, &len, NULL, NULL);
if (i) {
msgDebug("kget: error retrieving data\n");
return -1;
goto pnp;
}
/* now it's time to create the output file; if we end up not writing to
it, we'll unlink() it later. */
fout = fopen(out, "w");
if (fout == NULL) {
msgDebug("kget: Unable to open %s for writing.\n", out);
return -1;
}
i = 0;
while (i < len) {