Makes sense to me, ok.

Later we should fix the include orderning and change the warning
printfs to stderr. 

Can we get another ok ?

On Wed, Sep 28, 2011 at 02:37:34AM +0100, Edd Barrett wrote:
> Evening,
> 
> 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?
> 
> Index: exec.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/config/exec.c,v
> retrieving revision 1.7
> diff -u -r1.7 exec.c
> --- exec.c    27 Oct 2009 23:59:51 -0000      1.7
> +++ exec.c    28 Sep 2011 01:19:49 -0000
> @@ -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 @@
>  void
>  loadkernel(char *file)
>  {
> +     struct stat                     st;
> +
> +     if (stat(file, &st) == -1)
> +             err(1, "cannot stat '%s'", file);
> +
>       current_exec = -1;
>  
>  #ifdef AOUT_SUPPORT
> Index: ukc.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/config/ukc.c,v
> retrieving revision 1.16
> diff -u -r1.16 ukc.c
> --- ukc.c     10 Dec 2009 22:07:19 -0000      1.16
> +++ ukc.c     28 Sep 2011 01:19:49 -0000
> @@ -114,10 +114,8 @@
>               }
>       }
>  
> -     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 @@
>                       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 @@
>       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;
> 
> -- 
> Best Regards
> Edd Barrett

Reply via email to