|
From: Nicholas N. <nj...@ca...> - 2003-11-13 09:13:39
|
On Thu, 13 Nov 2003, Anders Torger wrote: > I'm using valgrind-20031012 as distributed in debian unstable. > > I got this warning, and I think it is invalid: > > ==8200== Source and destination overlap in strncpy(0x412deab0,0x412dea78,256) > ==8200== at 0x400240ED: strncpy (mac_replace_strmem.c:95) > > As you can see, the source address is before the destination address, closer > than 256 bytes, which is the strncpy limit in this call. This can happen when > the source string is shorter than 256 bytes (which it is in this case), but > valgrind reports it as an error anyway. > > Since the source address contains a string which is shorter than 256 bytes, > malloc happened to put the block closer than that to the destination. The way > strncpy works, there can never be a an overlap in this situation if indeed > the string is short enough to fit. The copying from the source will stop > where the string ends, if it ends before the 256 byte limit. > > However, if the source and destination addresses had been swapped in the above > example, the Valgrind report would have been correct. It's been fixed in 2.0.0, which you can get from the new website, at valgrind.kde.org. Thanks for the report. N |