tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: alignement or compiler bug?



Valeriy E. Ushakov <uwe%stderr.spb.ru@localhost> wrote:

> Emmanuel Dreyfus <manu%netbsd.org@localhost> wrote:
> 
>> This code wil rarely crash in memcpy(). gdb shows an unexpectely huge
>> data_len, bigger than max_write. My explanation this that memcpy overwrite
>> data_len becaue (fwi +1) did not hold the expected value.

Actually...

        written = 0;
        ...
        do {
                ...
                (void)memcpy((fwi + 1), buf + written, data_len);
                ...
                written = fwo->size;
                ...
                buf += written;
                ...
        } ...

so, unless I miss something, on the second iteration the second
(source) arg to memcpy is going to be wrong, as you add written twice.

-uwe



Home | Main Index | Thread Index | Old Index