svn commit: r280953 - head/sys/boot/i386/libi386

Roger Pau Monné royger at FreeBSD.org
Wed Apr 1 10:02:30 UTC 2015


Author: royger
Date: Wed Apr  1 10:02:28 2015
New Revision: 280953
URL: https://svnweb.freebsd.org/changeset/base/280953

Log:
  multiboot: zero mod list array
  
  Zero the list of modules array before using it, or else we might pass
  uninitialized data in unused fields of the struct that will make Xen choke.
  Also add a check to make sure malloc succeeds.
  
  Sponsored by: Citrix Systems R&D

Modified:
  head/sys/boot/i386/libi386/multiboot.c

Modified: head/sys/boot/i386/libi386/multiboot.c
==============================================================================
--- head/sys/boot/i386/libi386/multiboot.c	Wed Apr  1 08:37:50 2015	(r280952)
+++ head/sys/boot/i386/libi386/multiboot.c	Wed Apr  1 10:02:28 2015	(r280953)
@@ -274,7 +274,14 @@ multiboot_exec(struct preloaded_file *fp
 		error = EFTYPE;
 		goto error;
 	}
+
 	mb_mod = malloc(sizeof(struct multiboot_mod_list) * NUM_MODULES);
+	if (mb_mod == NULL) {
+		error = ENOMEM;
+		goto error;
+	}
+
+	bzero(mb_mod, sizeof(struct multiboot_mod_list) * NUM_MODULES);
 
 	/*
 	 * Calculate how much memory is needed for the metatdata. We did


More information about the svn-src-head mailing list