[coreboot] [PATCH] flashrom: Improve coreboot image detection heuristic

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Fri Jul 4 18:11:54 CEST 2008


On 04.07.2008 15:28, Stefan Reinauer wrote:
> Carl-Daniel Hailfinger wrote:
>   
>> On 03.07.2008 18:46, Peter Stuge wrote:
>>   
>>     
>>> On Thu, Jul 03, 2008 at 04:28:54PM +0200, Carl-Daniel Hailfinger wrote:
>>>   
>>>     
>>>       
>>>> +	if ((*walk) == 0 || ((*walk) & 0x3ff) != 0 || *walk > size ||
>>>> +		*(walk - 1) > size || *(walk - 2) > size ||
>>>> +		(!isprint((const char *)(bios + size - *(walk - 1))) &&
>>>> +		((const char *)(bios + size - *(walk - 1)))) ||
>>>> +		(!isprint((const char *)(bios + size - *(walk - 2))) &&
>>>> +		((const char *)(bios + size - *(walk - 2))))) {
>>>>     
>>>>       
>>>>         
>>> I am in total disbelief. I should probably not be wasting any more of
>>> my time on cleanups and restructuring.
>>>   
>>>     
>>>       
>> Well, this is the only reliable fix until somebody steps forward to
>> implement LAR recognition for flashrom and fake LAR headers for v2 and
>> we agree on a standard for encapsulating vendor/model information in a
>> LAR. I don't see that happening in the next few weeks.
>>   
>>     
> Reliable yes, but reliably wrong, unfortunately. It checks whether a
> pointer is printable, which makes absolutely no sense.
> Shame on me I acked this.
>   

Sorry. I had a correct version, but it seems I pressed undo before saving.

Fix coreboot image detection heuristic.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Index: flashrom-tmp1/layout.c
===================================================================
--- flashrom-tmp1/layout.c	(Revision 3412)
+++ flashrom-tmp1/layout.c	(Arbeitskopie)
@@ -65,10 +65,10 @@
 	 */
 	if ((*walk) == 0 || ((*walk) & 0x3ff) != 0 || *walk > size ||
 		*(walk - 1) > size || *(walk - 2) > size ||
-		(!isprint((const char *)(bios + size - *(walk - 1))) &&
-		((const char *)(bios + size - *(walk - 1)))) ||
-		(!isprint((const char *)(bios + size - *(walk - 2))) &&
-		((const char *)(bios + size - *(walk - 2))))) {
+		(!isprint(*(const char *)(bios + size - *(walk - 1))) &&
+		(*(const char *)(bios + size - *(walk - 1)))) ||
+		(!isprint(*(const char *)(bios + size - *(walk - 2))) &&
+		(*(const char *)(bios + size - *(walk - 2))))) {
 		printf("Flash image seems to be a legacy BIOS. Disabling checks.\n");
 		mainboard_vendor = def_name;
 		mainboard_part = def_name;


-- 
http://www.hailfinger.org/





More information about the coreboot mailing list