Author: brucec
Date: Sat Feb 26 12:04:34 2011
New Revision: 219053
URL: http://svn.freebsd.org/changeset/base/219053

Log:
  MFC r218974:
  
  Handle memory allocation failures in include().
  
  Fix a format specifier in libefi: status is an unsigned int, not unsigned
  long.
  
  PR:           i386/85652
  Submitted by: Ben Thomas <bthomas at virtualiron.com>

Modified:
  stable/8/sys/boot/common/interp.c
  stable/8/sys/boot/efi/libefi/efipart.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/boot/common/interp.c
==============================================================================
--- stable/8/sys/boot/common/interp.c   Sat Feb 26 11:52:34 2011        
(r219052)
+++ stable/8/sys/boot/common/interp.c   Sat Feb 26 12:04:34 2011        
(r219053)
@@ -246,6 +246,17 @@ include(const char *filename)
        if (*cp == '\0')
                continue;       /* ignore empty line, save memory */
        sp = malloc(sizeof(struct includeline) + strlen(cp) + 1);
+       /* On malloc failure (it happens!), free as much as possible and exit */
+       if (sp == NULL) {
+               while (script != NULL) {
+                       se = script;
+                       script = script->next;
+                       free(se);
+               }
+               sprintf(command_errbuf, "file '%s' line %d: memory allocation "
+                   "failure - aborting\n", filename, line);
+               return (CMD_ERROR);
+       }
        strcpy(sp->text, cp);
 #ifndef BOOT_FORTH
        sp->flags = flags;

Modified: stable/8/sys/boot/efi/libefi/efipart.c
==============================================================================
--- stable/8/sys/boot/efi/libefi/efipart.c      Sat Feb 26 11:52:34 2011        
(r219052)
+++ stable/8/sys/boot/efi/libefi/efipart.c      Sat Feb 26 12:04:34 2011        
(r219053)
@@ -203,7 +203,7 @@ efipart_readwrite(EFI_BLOCK_IO *blkio, i
        }
 
        if (EFI_ERROR(status))
-               printf("%s: rw=%d, status=%lu\n", __func__, rw, status);
+               printf("%s: rw=%d, status=%u\n", __func__, rw, status);
        return (efi_status_to_errno(status));
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to