Changeset 3420
- Timestamp:
- 07/11/08 02:06:38 (3 months ago)
- Files:
-
- 1 modified
-
trunk/util/flashrom/layout.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/util/flashrom/layout.c
r3412 r3420 46 46 { 47 47 unsigned int *walk; 48 unsigned int mb_part_offset, mb_vendor_offset; 49 char *mb_part, *mb_vendor; 50 51 mainboard_vendor = def_name; 52 mainboard_part = def_name; 48 53 49 54 walk = (unsigned int *)(bios + size - 0x10); … … 64 69 * (nonprintable and not \0). 65 70 */ 66 if ((*walk) == 0 || ((*walk) & 0x3ff) != 0 || *walk > size || 67 *(walk - 1) > size || *(walk - 2) > size || 68 (!isprint((const char *)(bios + size - *(walk - 1))) && 69 ((const char *)(bios + size - *(walk - 1)))) || 70 (!isprint((const char *)(bios + size - *(walk - 2))) && 71 ((const char *)(bios + size - *(walk - 2))))) { 71 mb_part_offset = *(walk - 1); 72 mb_vendor_offset = *(walk - 2); 73 if ((*walk) == 0 || ((*walk) & 0x3ff) != 0 || (*walk) > size || 74 mb_part_offset > size || mb_vendor_offset > size) { 72 75 printf("Flash image seems to be a legacy BIOS. Disabling checks.\n"); 73 mainboard_vendor = def_name; 74 mainboard_part = def_name; 76 return 0; 77 } 78 79 mb_part = (char *)(bios + size - mb_part_offset); 80 mb_vendor = (char *)(bios + size - mb_vendor_offset); 81 if (!isprint((unsigned char)*mb_part) || 82 !isprint((unsigned char)*mb_vendor)) { 83 printf("Flash image seems to have garbage in the ID location." 84 " Disabling checks.\n"); 75 85 return 0; 76 86 } … … 79 89 "(not ROM size) is %d bytes.\n", *walk); 80 90 81 walk--; 82 mainboard_part = strdup((const char *)(bios + size - *walk)); 83 walk--; 84 mainboard_vendor = strdup((const char *)(bios + size - *walk)); 91 mainboard_part = strdup(mb_part); 92 mainboard_vendor = strdup(mb_vendor); 85 93 printf_debug("Manufacturer: %s\n", mainboard_vendor); 86 94 printf_debug("Mainboard ID: %s\n", mainboard_part);
