diff options
Diffstat (limited to 'usr/src/cmd/boot')
-rw-r--r-- | usr/src/cmd/boot/bootadm/Makefile | 4 | ||||
-rw-r--r-- | usr/src/cmd/boot/common/mboot_extra.c | 9 | ||||
-rw-r--r-- | usr/src/cmd/boot/common/mboot_extra.h | 3 | ||||
-rw-r--r-- | usr/src/cmd/boot/installboot/Makefile | 1 | ||||
-rw-r--r-- | usr/src/cmd/boot/installboot/installboot.c | 9 | ||||
-rw-r--r-- | usr/src/cmd/boot/installboot/installboot.h | 2 | ||||
-rw-r--r-- | usr/src/cmd/boot/installgrub/Makefile | 3 | ||||
-rw-r--r-- | usr/src/cmd/boot/installgrub/installgrub.c | 8 | ||||
-rw-r--r-- | usr/src/cmd/boot/installgrub/installgrub.h | 2 | ||||
-rw-r--r-- | usr/src/cmd/boot/mbr/Makefile | 4 |
10 files changed, 35 insertions, 10 deletions
diff --git a/usr/src/cmd/boot/bootadm/Makefile b/usr/src/cmd/boot/bootadm/Makefile index 2b0d2cb358..e3f67930ff 100644 --- a/usr/src/cmd/boot/bootadm/Makefile +++ b/usr/src/cmd/boot/bootadm/Makefile @@ -46,6 +46,10 @@ CFLAGS += $(XSTRCONST) CPPFLAGS += -D_FILE_OFFSET_BITS=64 CPPFLAGS += -I../../../uts/common -I../../../common +CERRWARN += -_gcc=-Wno-parentheses +CERRWARN += -_gcc=-Wno-uninitialized +CERRWARN += -_gcc=-Wno-unused-label + LINTFLAGS += -erroff=E_INCONS_ARG_DECL2 LINTFLAGS += -erroff=E_INCONS_VAL_TYPE_DECL2 LINTFLAGS += -erroff=E_NAME_DEF_NOT_USED2 diff --git a/usr/src/cmd/boot/common/mboot_extra.c b/usr/src/cmd/boot/common/mboot_extra.c index d8f5fa346d..170d638bb5 100644 --- a/usr/src/cmd/boot/common/mboot_extra.c +++ b/usr/src/cmd/boot/common/mboot_extra.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. */ #include <stdio.h> @@ -107,7 +108,7 @@ find_multiboot(char *buffer, uint32_t buf_size, uint32_t *mboot_off) * + payload chunks), find the extended information structure. */ bblk_einfo_t * -find_einfo(char *extra) +find_einfo(char *extra, uint32_t size) { bb_header_ext_t *ext_header; bblk_einfo_t *einfo; @@ -116,6 +117,12 @@ find_einfo(char *extra) assert(extra != NULL); ext_header = (bb_header_ext_t *)extra; + if (ext_header->size > size) { + BOOT_DEBUG("Unable to find extended versioning information, " + "data size too big\n"); + return (NULL); + } + cksum = compute_checksum(extra + sizeof (bb_header_ext_t), ext_header->size); BOOT_DEBUG("Extended information header checksum is %x\n", cksum); diff --git a/usr/src/cmd/boot/common/mboot_extra.h b/usr/src/cmd/boot/common/mboot_extra.h index ba60351718..fb48c52a69 100644 --- a/usr/src/cmd/boot/common/mboot_extra.h +++ b/usr/src/cmd/boot/common/mboot_extra.h @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. */ #ifndef _MBOOT_EXTRA_H @@ -46,7 +47,7 @@ typedef struct _bb_extra_header { } bb_header_ext_t; uint32_t compute_checksum(char *, uint32_t); -bblk_einfo_t *find_einfo(char *); +bblk_einfo_t *find_einfo(char *, uint32_t); int find_multiboot(char *, uint32_t, uint32_t *); void add_einfo(char *, char *, bblk_hs_t *, uint32_t); int compare_bootblocks(char *, char *, char **); diff --git a/usr/src/cmd/boot/installboot/Makefile b/usr/src/cmd/boot/installboot/Makefile index 5dc4eb13b5..e2fcf37f84 100644 --- a/usr/src/cmd/boot/installboot/Makefile +++ b/usr/src/cmd/boot/installboot/Makefile @@ -40,6 +40,7 @@ C99MODE= -xc99=%all C99LMODE= -Xc99=%all LINTFLAGS += -erroff=E_BAD_PTR_CAST_ALIGN +CERRWARN += -_gcc=-Wno-uninitialized .KEEP_STATE: diff --git a/usr/src/cmd/boot/installboot/installboot.c b/usr/src/cmd/boot/installboot/installboot.c index cab6670608..2a4f48fd18 100644 --- a/usr/src/cmd/boot/installboot/installboot.c +++ b/usr/src/cmd/boot/installboot/installboot.c @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. */ #include <stdio.h> @@ -252,6 +253,8 @@ read_bootblock_from_disk(int dev_fd, ib_bootblock_t *bblock) bblock->mboot = (multiboot_header_t *)(bblock->buf + bblock->mboot_off + BBLK_DATA_RSVD_SIZE); bblock->extra = (char *)bblock->mboot + sizeof (multiboot_header_t); + bblock->extra_size = bblock->buf_size - bblock->mboot_off + - BBLK_DATA_RSVD_SIZE - sizeof (multiboot_header_t); return (BC_SUCCESS); } @@ -279,7 +282,7 @@ is_update_necessary(ib_data_t *data, char *updt_str) return (B_TRUE); } - einfo = find_einfo(bblock_disk.extra); + einfo = find_einfo(bblock_disk.extra, bblock_disk.extra_size); if (einfo == NULL) { BOOT_DEBUG("No extended information available\n"); return (B_TRUE); @@ -716,7 +719,7 @@ handle_getinfo(char *progname, char **argv) goto out_dev; } - einfo = find_einfo(bblock->extra); + einfo = find_einfo(bblock->extra, bblock->extra_size); if (einfo == NULL) { retval = BC_NOEINFO; (void) fprintf(stderr, gettext("No extended information " @@ -817,7 +820,7 @@ handle_mirror(char *progname, char **argv) goto out_devs; } - einfo_curr = find_einfo(bblock_curr->extra); + einfo_curr = find_einfo(bblock_curr->extra, bblock_curr->extra_size); if (einfo_curr != NULL) updt_str = einfo_get_string(einfo_curr); diff --git a/usr/src/cmd/boot/installboot/installboot.h b/usr/src/cmd/boot/installboot/installboot.h index 7b558b3846..2fa7ad2561 100644 --- a/usr/src/cmd/boot/installboot/installboot.h +++ b/usr/src/cmd/boot/installboot/installboot.h @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. */ #ifndef _INSTALLBOOT_H @@ -52,6 +53,7 @@ typedef struct _ib_bootblock { uint32_t mboot_off; uint32_t buf_size; uint32_t file_size; + uint32_t extra_size; } ib_bootblock_t; typedef struct _ib_data { diff --git a/usr/src/cmd/boot/installgrub/Makefile b/usr/src/cmd/boot/installgrub/Makefile index bf3d73ab70..4cc69eccd5 100644 --- a/usr/src/cmd/boot/installgrub/Makefile +++ b/usr/src/cmd/boot/installgrub/Makefile @@ -36,6 +36,9 @@ SBINLINKS= $(PROG) include ../Makefile.com CPPFLAGS += -I$(SRC)/uts/i86pc -I$(SRC)/uts/intel -I$(SRC)/uts/common +CERRWARN += -_gcc=-Wno-unused-label +CERRWARN += -_gcc=-Wno-unused-function +CERRWARN += -_gcc=-Wno-uninitialized LDLIBS += -lmd5 diff --git a/usr/src/cmd/boot/installgrub/installgrub.c b/usr/src/cmd/boot/installgrub/installgrub.c index 3df067420c..c27dca802b 100644 --- a/usr/src/cmd/boot/installgrub/installgrub.c +++ b/usr/src/cmd/boot/installgrub/installgrub.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2012 Milan Jurik. All rights reserved. + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. */ #include <stdio.h> @@ -403,7 +404,7 @@ handle_getinfo(char *progname, char **argv) goto out_dev; } - einfo = find_einfo(stage2->extra); + einfo = find_einfo(stage2->extra, stage2->extra_size); if (einfo == NULL) { retval = BC_NOEINFO; (void) fprintf(stderr, gettext("No extended information " @@ -501,7 +502,7 @@ handle_mirror(char *progname, char **argv) goto out_devs; } - einfo_curr = find_einfo(stage2_curr->extra); + einfo_curr = find_einfo(stage2_curr->extra, stage2_curr->extra_size); if (einfo_curr != NULL) updt_str = einfo_get_string(einfo_curr); @@ -1221,6 +1222,7 @@ read_stage2_from_disk(int dev_fd, ig_stage2_t *stage2) stage2->mboot_off = mboot_off; stage2->mboot = (multiboot_header_t *)(stage2->buf + stage2->mboot_off); stage2->extra = stage2->buf + P2ROUNDUP(stage2->file_size, 8); + stage2->extra_size = stage2->buf_size - P2ROUNDUP(stage2->file_size, 8); return (BC_SUCCESS); } @@ -1251,7 +1253,7 @@ is_update_necessary(ig_data_t *data, char *updt_str) * Look for the extended information structure in the extra payload * area. */ - einfo = find_einfo(stage2_disk.extra); + einfo = find_einfo(stage2_disk.extra, stage2_disk.extra_size); if (einfo == NULL) { BOOT_DEBUG("No extended information available\n"); return (B_TRUE); diff --git a/usr/src/cmd/boot/installgrub/installgrub.h b/usr/src/cmd/boot/installgrub/installgrub.h index e23d1c35d7..af6e60b973 100644 --- a/usr/src/cmd/boot/installgrub/installgrub.h +++ b/usr/src/cmd/boot/installgrub/installgrub.h @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. */ #ifndef _INSTALLGRUB_H @@ -53,6 +54,7 @@ typedef struct _stage2_data { multiboot_header_t *mboot; uint32_t mboot_off; uint32_t file_size; + uint32_t extra_size; uint32_t buf_size; uint32_t first_sector; uint32_t pcfs_first_sectors[2]; diff --git a/usr/src/cmd/boot/mbr/Makefile b/usr/src/cmd/boot/mbr/Makefile index 510257daac..8f18eaee27 100644 --- a/usr/src/cmd/boot/mbr/Makefile +++ b/usr/src/cmd/boot/mbr/Makefile @@ -22,8 +22,6 @@ # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" -# BOOTPROG= mbr @@ -32,6 +30,8 @@ SRCS = $(OBJS:.o=.c) include ../Makefile.com +CERRWARN += -_gcc=-Wno-parentheses + .KEEP_STATE: all: $(BOOTPROG) |