On Wed, Aug 28, 2002 at 10:13:30AM -0400, Morris Maynard wrote: > I think that Gilles found and fixed the problem correctly. The change > where he increased the size of the memory allocated to match the length of > the filename string is the key. Without that change, the byte just past > the end of the memory allocated doesn't really belong to the program, and > so could be written over by another process, or even by other code in the > same process. This is why the problem shows itself so randomly and why the > filename's ending character in the error log report differs from report to > report. > Thanks... That's exactly (or almost ;) what I thought but, as english isn't my native language, I didn't know the words to explain this. You've done this for me, thanks ! :)
> The other change, reducing the size of the malloc to match the > filename size, should not help in solving the problem, although it might > mask it; but it is more correct to only allocate the memory really > required. In fact, memory allocations really happen in blocks with a > minimum size to them, which increases the randomness of the symptoms; if a > short malloc ended up allocating just the amount of memory requested, and > the amount requested was too small by one byte, then that final byte would > be more likely to be overwritten; but if the memory manager allocated a > chunk that was really longer than absolutely needed anyway, then > overwriting the memory *might* make no difference. > In fact, I thought that if I was right for the ".diff" part of the code, there should also be an error for the ".db" part too (too much memory allocated in that case). > I am a C/C++ programmer, but that doesn't mean I swear I'm right about > this; it's been a long while since I wrote code for Unix and so the > particulars of Linux and GNU gcc's memory manager are unfamiliar to me. I > will say I'm mighty impressed that self-professed "non-C programmers" (or > should that be "C non-programmers?") came up with this solution. > I'm not capable of writing a simple "hello world" with C. So, trust me, we'll say I have had luck this time ;) Regards, Gilles. -- / Gilles CHAUVIN / CRDP de Haute-Normandie / / E-mail: [EMAIL PROTECTED] / GnuPG: 0x2E89DBB7 /
msg01193/pgp00000.pgp
Description: PGP signature
