strange problem with self-compiled software on FC 5 T2...
John Summerfied
debian at herakles.homelinux.org
Wed Feb 8 00:06:04 UTC 2006
Patrick von der Hagen wrote:
> Ulrich Drepper wrote:
>
>> Patrick von der Hagen wrote:
>>
>>> Now, whom should I contact? glibc, gnu-c or gnu-c++?
>>
>>
>> Nobody but the person who wrote that code. You pass a pointer to a
>> 'char' variable for the %s format element. Even *if* you only read one
>> character the terminating NUL byte will overwrite the next byte. That's
>> likely your variable 'j'.
>
> It's really amazing how many people missed that one and that several
> compilers (e.g. gnu-gcc/g++ 3.5) produced binaries that worked
> flawlessly. But you are right, "c" was placed next to "j" in memory, so
> j has been damaged by invocing fscanf. Fixing the format-string solved
> my problems.
>
> Sorry for all that noise.
I was suspicious, but my understanding of C is pretty limited (and will
stay that way; I reckon I know enough to know its failings).
Depending on the compiler, different optimisations could also
hide/reveal the problem.
It might be possible for the compiler to do better consistency checking,
but that won't help where the format string is created at run-time.
--
Cheers
John
-- spambait
1aaaaaaa at computerdatasafe.com.au Z1aaaaaaa at computerdatasafe.com.au
Tourist pics http://portgeographe.environmentaldisasters.cds.merseine.nu/
do not reply off-list
More information about the fedora-test-list
mailing list