WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Proactively check for NULL strings passed into xc_linux_

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Proactively check for NULL strings passed into xc_linux_build. Either DTRT
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 10 Jan 2006 22:02:10 +0000
Delivery-date: Tue, 10 Jan 2006 22:09:15 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 0a69deed5e1fbd7627f6c73a6ca494abb0ad0be2
# Parent  fbee8d9fbabae6a7a966a49f9fc4104e4fd9d97a
Proactively check for NULL strings passed into xc_linux_build.  Either DTRT
or return error if detected.  A NULL cmdline, for example, would currently
generate a segfault.

Signed-off-by: Ben Thomas  <bjthomas3@xxxxxxxxx>

diff -r fbee8d9fbaba -r 0a69deed5e1f tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Tue Jan 10 14:33:00 2006
+++ b/tools/libxc/xc_linux_build.c      Tue Jan 10 14:37:25 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';
+    } else
+        start_info->cmd_line[0] = '\0';
     munmap(start_info, PAGE_SIZE);
 
     /* shared_info page starts its life empty. */
@@ -755,7 +758,8 @@
         goto error_out;
     }
 
-    if ( (image = xc_read_kernel_image(image_name, &image_size)) == NULL )
+    if ( (image_name == NULL) ||
+         ((image = xc_read_kernel_image(image_name, &image_size)) == NULL) )
         goto error_out;
 
     if ( (ramdisk_name != NULL) && (strlen(ramdisk_name) != 0) )

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Proactively check for NULL strings passed into xc_linux_build. Either DTRT, Xen patchbot -unstable <=