[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Proactively check for NULL strings passed into xc_linx_build. Either do



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID c503c388797100b2492532fee4cbd48c71a85ce8
# Parent  d39fa3f09cb236321203d90651dc6ad245489b07
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@xxxxxxxxx>

diff -r d39fa3f09cb2 -r c503c3887971 tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Tue Jan 10 14:26:57 2006
+++ b/tools/libxc/xc_linux_build.c      Tue Jan 10 14:28:41 2006
@@ -693,8 +693,11 @@
         start_info->mod_start    = vinitrd_start;
         start_info->mod_len      = initrd_len;
     }
-    strncpy((char *)start_info->cmd_line, cmdline, MAX_GUEST_CMDLINE);
-    start_info->cmd_line[MAX_GUEST_CMDLINE-1] = '\0';
+    if ( cmdline != NULL )
+    {
+        strncpy((char *)start_info->cmd_line, cmdline, MAX_GUEST_CMDLINE);
+        start_info->cmd_line[MAX_GUEST_CMDLINE-1] = '\0';
+    }
     munmap(start_info, PAGE_SIZE);
 
     /* shared_info page starts its life empty. */
diff -r d39fa3f09cb2 -r c503c3887971 tools/libxc/xg_private.c
--- a/tools/libxc/xg_private.c  Tue Jan 10 14:26:57 2006
+++ b/tools/libxc/xg_private.c  Tue Jan 10 14:28:41 2006
@@ -16,6 +16,9 @@
     gzFile kernel_gfd = NULL;
     char *image = NULL;
     unsigned int bytes;
+
+    if ( filename == NULL )
+        goto out;
 
     if ( (kernel_fd = open(filename, O_RDONLY)) < 0 )
     {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.