Print this page
3027 installgrub can segfault when encountering bogus data on disk


  36 
  37 typedef struct _device_data {
  38         char            *path;
  39         char            *path_p0;
  40         uint8_t         type;
  41         int             part_fd;
  42         int             disk_fd;
  43         int             slice;
  44         int             partition;
  45         uint32_t        start_sector;
  46         char            boot_sector[SECTOR_SIZE];
  47 } ig_device_t;
  48 
  49 typedef struct _stage2_data {
  50         char                    *buf;
  51         char                    *file;
  52         char                    *extra;
  53         multiboot_header_t      *mboot;
  54         uint32_t                mboot_off;
  55         uint32_t                file_size;

  56         uint32_t                buf_size;
  57         uint32_t                first_sector;
  58         uint32_t                pcfs_first_sectors[2];
  59 } ig_stage2_t;
  60 
  61 typedef struct _ig_data {
  62         char            stage1_buf[SECTOR_SIZE];
  63         ig_stage2_t     stage2;
  64         ig_device_t     device;
  65 } ig_data_t;
  66 
  67 enum ig_devtype_t {
  68         IG_DEV_X86BOOTPAR = 1,
  69         IG_DEV_SOLVTOC
  70 };
  71 
  72 #define is_bootpar(type)        (type == IG_DEV_X86BOOTPAR)
  73 
  74 #define STAGE2_MEMADDR          (0x8000)        /* loading addr of stage2 */
  75 


  36 
  37 typedef struct _device_data {
  38         char            *path;
  39         char            *path_p0;
  40         uint8_t         type;
  41         int             part_fd;
  42         int             disk_fd;
  43         int             slice;
  44         int             partition;
  45         uint32_t        start_sector;
  46         char            boot_sector[SECTOR_SIZE];
  47 } ig_device_t;
  48 
  49 typedef struct _stage2_data {
  50         char                    *buf;
  51         char                    *file;
  52         char                    *extra;
  53         multiboot_header_t      *mboot;
  54         uint32_t                mboot_off;
  55         uint32_t                file_size;
  56         uint32_t                extra_size;
  57         uint32_t                buf_size;
  58         uint32_t                first_sector;
  59         uint32_t                pcfs_first_sectors[2];
  60 } ig_stage2_t;
  61 
  62 typedef struct _ig_data {
  63         char            stage1_buf[SECTOR_SIZE];
  64         ig_stage2_t     stage2;
  65         ig_device_t     device;
  66 } ig_data_t;
  67 
  68 enum ig_devtype_t {
  69         IG_DEV_X86BOOTPAR = 1,
  70         IG_DEV_SOLVTOC
  71 };
  72 
  73 #define is_bootpar(type)        (type == IG_DEV_X86BOOTPAR)
  74 
  75 #define STAGE2_MEMADDR          (0x8000)        /* loading addr of stage2 */
  76