[PATCH] memcmp() error in gas/dwarf2dbg.c

Hannes Reinecke hare@suse.de
Fri Feb 13 11:58:00 GMT 2004


Jakub Jelinek wrote:
> On Fri, Feb 13, 2004 at 12:21:30PM +0100, Andreas Jaeger wrote:
> 
>>>--- binutils-2.14.90.0.8/gas/dwarf2dbg..c.orig	2004-02-13 11:55:05.470239719 +0100
>>>+++ binutils-2.14.90.0.8/gas/dwarf2dbg.c	2004-02-13 11:57:23.679576129 +0100
>>
>>Note this patch applies also to current CVS, Hannes noticed it with a
>>segmentation fault of gas due to accessing beyond the allocated memory.
>>
>>
[ Patch deleted ]
> 
> 
> I very much doubt it has been tested at all.
> Previously it has been doing if (...) break; in the for cycle, now
> it does just tmp_len = in the for cycle and if (...) break; afterwards.
> Also, calling strlen twice is a waste, relying on compiler to optimize
> it out is wrong.  And doing even one strlen in the cycle is too expensive.
> I believe using
> strncmp (filename, dirs[dir], dir_len) == 0 && dirs[dir][dir_len] == '\0'
> would be much better.
> 

Like this?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke			hare@suse.de
SuSE Linux AG				S390 & zSeries
Maxfeldstraße 5				+49 911 74053 688
90409 Nürnberg				http://www.suse.de
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: gas-check-memcmp.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20040213/c3d83c54/attachment.ksh>


More information about the Binutils mailing list