/[grub]/grub2/loader/i386/pc/multiboot.c
ViewVC logotype

Diff of /grub2/loader/i386/pc/multiboot.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by okuji, Sun Apr 4 13:46:02 2004 UTC revision 1.6 by marco_g, Mon Feb 14 18:41:33 2005 UTC
# Line 1  Line 1 
1  /* multiboot.c - boot a multiboot OS image. */  /* multiboot.c - boot a multiboot OS image. */
2  /*  /*
3   *  GRUB  --  GRand Unified Bootloader   *  GRUB  --  GRand Unified Bootloader
4   *  Copyright (C) 2003, 2004  Free Software Foundation, Inc.   *  Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
5   *   *
6   *  This program is free software; you can redistribute it and/or modify   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by   *  it under the terms of the GNU General Public License as published by
# Line 140  grub_rescue_cmd_multiboot (int argc, cha Line 140  grub_rescue_cmd_multiboot (int argc, cha
140    
141    ehdr = (Elf32_Ehdr *) buffer;    ehdr = (Elf32_Ehdr *) buffer;
142    
143    if (!((ehdr->e_ident[EI_MAG0] == ELFMAG0)    if (grub_dl_check_header (ehdr, sizeof(*ehdr)))
         && (ehdr->e_ident[EI_MAG1] == ELFMAG1)  
         && (ehdr->e_ident[EI_MAG2] == ELFMAG2)  
         && (ehdr->e_ident[EI_MAG3] == ELFMAG3)  
         && (ehdr->e_ident[EI_CLASS] == ELFCLASS32)  
         && (ehdr->e_ident[EI_DATA] == ELFDATA2LSB)  
         && (ehdr->e_ident[EI_VERSION] == EV_CURRENT)  
         && (ehdr->e_type == ET_EXEC) && (ehdr->e_machine == EM_386)  
         && (ehdr->e_version == EV_CURRENT)))  
144      {      {
145        grub_error (GRUB_ERR_UNKNOWN_OS, "No valid ELF header found");        grub_error (GRUB_ERR_UNKNOWN_OS, "No valid ELF header found");
146        goto fail;        goto fail;
147      }      }
148    
149      if (ehdr->e_type != ET_EXEC)
150        {
151          grub_error (GRUB_ERR_UNKNOWN_OS, "invalid ELF file type");
152          goto fail;
153        }
154    
155    /* FIXME: Should we support program headers at strange locations?  */    /* FIXME: Should we support program headers at strange locations?  */
156    if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > GRUB_MB_SEARCH)    if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > GRUB_MB_SEARCH)
157      {      {

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26