ia64/xen-unstable

changeset 8538:c503c3887971

Proactively check for NULL strings passed into xc_linx_build. Either do
the right thing or return error if detected. A NULL cmdline, for example,
would currently generate a segfault.

Signed-off-by: Ben Thomas <bjthomas3@gmail.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Jan 10 15:28:41 2006 +0100 (2006-01-10)
parents d39fa3f09cb2
children fa3a37839eb7
files tools/libxc/xc_linux_build.c tools/libxc/xg_private.c
line diff
     1.1 --- a/tools/libxc/xc_linux_build.c	Tue Jan 10 15:26:57 2006 +0100
     1.2 +++ b/tools/libxc/xc_linux_build.c	Tue Jan 10 15:28:41 2006 +0100
     1.3 @@ -693,8 +693,11 @@ static int setup_guest(int xc_handle,
     1.4          start_info->mod_start    = vinitrd_start;
     1.5          start_info->mod_len      = initrd_len;
     1.6      }
     1.7 -    strncpy((char *)start_info->cmd_line, cmdline, MAX_GUEST_CMDLINE);
     1.8 -    start_info->cmd_line[MAX_GUEST_CMDLINE-1] = '\0';
     1.9 +    if ( cmdline != NULL )
    1.10 +    {
    1.11 +        strncpy((char *)start_info->cmd_line, cmdline, MAX_GUEST_CMDLINE);
    1.12 +        start_info->cmd_line[MAX_GUEST_CMDLINE-1] = '\0';
    1.13 +    }
    1.14      munmap(start_info, PAGE_SIZE);
    1.15  
    1.16      /* shared_info page starts its life empty. */
     2.1 --- a/tools/libxc/xg_private.c	Tue Jan 10 15:26:57 2006 +0100
     2.2 +++ b/tools/libxc/xg_private.c	Tue Jan 10 15:28:41 2006 +0100
     2.3 @@ -17,6 +17,9 @@ char *xc_read_kernel_image(const char *f
     2.4      char *image = NULL;
     2.5      unsigned int bytes;
     2.6  
     2.7 +    if ( filename == NULL )
     2.8 +        goto out;
     2.9 +
    2.10      if ( (kernel_fd = open(filename, O_RDONLY)) < 0 )
    2.11      {
    2.12          PERROR("Could not open kernel image");