summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdd Barrett <edd@cvs.openbsd.org>2011-10-02 10:10:31 +0000
committerEdd Barrett <edd@cvs.openbsd.org>2011-10-02 10:10:31 +0000
commitbc0f578bdc04f48931b8959075c099b73ae74b4b (patch)
tree03faf09e0341bfdcd49493d42ded1c72e12ce279
parent07530f7ca9eacf47c24ffe66d5a1e7c6d5d8bbb4 (diff)
When using `config -e`:
* Don't print a NULL pointer if binary loaded is not a kernel. * Don't segfault of binary loaded is not a kernel. * Report non-existent kernel via a preliminary stat(). * Make a warning look like the rest. OK haesbaert@, nicm@
-rw-r--r--usr.sbin/config/exec.c9
-rw-r--r--usr.sbin/config/ukc.c12
2 files changed, 15 insertions, 6 deletions
diff --git a/usr.sbin/config/exec.c b/usr.sbin/config/exec.c
index 8bcfb7c5caa..6bf3a6a00cc 100644
--- a/usr.sbin/config/exec.c
+++ b/usr.sbin/config/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.7 2009/10/27 23:59:51 deraadt Exp $ */
+/* $OpenBSD: exec.c,v 1.8 2011/10/02 10:10:30 edd Exp $ */
/*
* Copyright (c) 1999 Mats O Jansson. All rights reserved.
@@ -26,6 +26,8 @@
#include <err.h>
#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include <stdio.h>
#ifdef AOUT_SUPPORT
@@ -109,6 +111,11 @@ readjust(caddr_t x)
void
loadkernel(char *file)
{
+ struct stat st;
+
+ if (stat(file, &st) == -1)
+ err(1, "cannot stat '%s'", file);
+
current_exec = -1;
#ifdef AOUT_SUPPORT
diff --git a/usr.sbin/config/ukc.c b/usr.sbin/config/ukc.c
index 05a367c405e..1ff7be614f1 100644
--- a/usr.sbin/config/ukc.c
+++ b/usr.sbin/config/ukc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukc.c,v 1.16 2009/12/10 22:07:19 kettenis Exp $ */
+/* $OpenBSD: ukc.c,v 1.17 2011/10/02 10:10:30 edd Exp $ */
/*
* Copyright (c) 1999-2001 Mats O Jansson. All rights reserved.
@@ -114,10 +114,8 @@ ukc(char *file, char *outfile, int uflag, int force)
}
}
- printf("%s", adjust((caddr_t)nl[P_VERSION].n_value));
-
if (force == 0 && outfile == NULL)
- printf("warning: no output file specified\n");
+ printf("WARNING no output file specified\n");
if (nl[IA_EXTRALOC].n_type == 0 || nl[I_NEXTRALOC].n_type == 0 ||
nl[I_UEXTRALOC].n_type == 0 || nl[I_HISTLEN].n_type == 0 ||
@@ -155,6 +153,8 @@ WARNING this kernel doesn't support pseudo devices.\n");
process_history(histlen, history);
}
+ printf("%s", adjust((caddr_t)nl[P_VERSION].n_value));
+
if (config()) {
if (force == 0 && outfile == NULL) {
fprintf(stderr, "not forced\n");
@@ -184,7 +184,9 @@ init(void)
struct winsize w;
#endif
- cd = get_cfdata(0); /* get first item */
+ if ((cd = get_cfdata(0)) == NULL) /* get first item */
+ errx(1, "failed to get first cfdata");
+
while (cd->cf_attach != 0) {
maxdev = i;
totdev = i;