Ticket #102: flashrom_layout_better_coreboot_heuristic.diff

File flashrom_layout_better_coreboot_heuristic.diff, 1.1 KB (added by hailfinger, 5 months ago)
  • flashrom-tmp1/layout.c

     
    2121#include <stdio.h> 
    2222#include <stdlib.h> 
    2323#include <string.h> 
     24#include <ctype.h> 
    2425#include <stdint.h> 
    2526#include "flash.h" 
    2627 
     
    5758                walk--; 
    5859        } 
    5960 
    60         if ((*walk) == 0 || ((*walk) & 0x3ff) != 0) { 
     61        /* 
     62         * Check if coreboot last image size is 0 or not a multiple of 1k or 
     63         * bigger than the chip or if the pointers to vendor ID or mainboard ID 
     64         * are outside the image of if the start of ID strings are nonsensical 
     65         * (nonprintable and not \0). 
     66         */ 
     67        if ((*walk) == 0 || ((*walk) & 0x3ff) != 0 || *walk > size || 
     68                *(walk - 1) > size || *(walk - 2) > size || 
     69                (!isprint((const char *)(bios + size - *(walk - 1))) && 
     70                ((const char *)(bios + size - *(walk - 1)))) || 
     71                (!isprint((const char *)(bios + size - *(walk - 2))) && 
     72                ((const char *)(bios + size - *(walk - 2))))) { 
    6173                printf("Flash image seems to be a legacy BIOS. Disabling checks.\n"); 
    6274                mainboard_vendor = def_name; 
    6375                mainboard_part = def_name;