Print this page
3027 installgrub can segfault when encountering bogus data on disk
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/boot/installgrub/installgrub.h
+++ new/usr/src/cmd/boot/installgrub/installgrub.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24
25 25 #ifndef _INSTALLGRUB_H
26 26 #define _INSTALLGRUB_H
27 27
28 28 #ifdef __cplusplus
29 29 extern "C" {
30 30 #endif
31 31
32 32 #include <sys/multiboot.h>
33 33 #include "./../common/bblk_einfo.h"
34 34
35 35 #define SECTOR_SIZE (512)
36 36
37 37 typedef struct _device_data {
38 38 char *path;
39 39 char *path_p0;
40 40 uint8_t type;
41 41 int part_fd;
42 42 int disk_fd;
43 43 int slice;
44 44 int partition;
45 45 uint32_t start_sector;
↓ open down ↓ |
45 lines elided |
↑ open up ↑ |
46 46 char boot_sector[SECTOR_SIZE];
47 47 } ig_device_t;
48 48
49 49 typedef struct _stage2_data {
50 50 char *buf;
51 51 char *file;
52 52 char *extra;
53 53 multiboot_header_t *mboot;
54 54 uint32_t mboot_off;
55 55 uint32_t file_size;
56 + uint32_t extra_size;
56 57 uint32_t buf_size;
57 58 uint32_t first_sector;
58 59 uint32_t pcfs_first_sectors[2];
59 60 } ig_stage2_t;
60 61
61 62 typedef struct _ig_data {
62 63 char stage1_buf[SECTOR_SIZE];
63 64 ig_stage2_t stage2;
64 65 ig_device_t device;
65 66 } ig_data_t;
66 67
67 68 enum ig_devtype_t {
68 69 IG_DEV_X86BOOTPAR = 1,
69 70 IG_DEV_SOLVTOC
70 71 };
71 72
72 73 #define is_bootpar(type) (type == IG_DEV_X86BOOTPAR)
73 74
74 75 #define STAGE2_MEMADDR (0x8000) /* loading addr of stage2 */
75 76
76 77 #define STAGE1_BPB_OFFSET (0x3)
77 78 #define STAGE1_BPB_SIZE (0x3B)
78 79 #define STAGE1_BOOT_DRIVE (0x40)
79 80 #define STAGE1_FORCE_LBA (0x41)
80 81 #define STAGE1_STAGE2_ADDRESS (0x42)
81 82 #define STAGE1_STAGE2_SECTOR (0x44)
82 83 #define STAGE1_STAGE2_SEGMENT (0x48)
83 84
84 85 #define STAGE2_BLOCKLIST (SECTOR_SIZE - 0x8)
85 86 #define STAGE2_INSTALLPART (SECTOR_SIZE + 0x8)
86 87 #define STAGE2_FORCE_LBA (SECTOR_SIZE + 0x11)
87 88 #define STAGE2_BLKOFF (50) /* offset from start of fdisk part */
88 89
89 90 #ifdef __cplusplus
90 91 }
91 92 #endif
92 93
93 94 #endif /* _INSTALLGRUB_H */
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX