Hi,

I am looking for random cache corruption problem. Not sure what is wrong, so
I just started a code inspection of the diskcache.c

Came across some read/write without error checks.

file diskcache.c function

rewriteEntry(ObjectPtr object)

{
....
    while(1) {
        CHECK_ENTRY(entry);
        n = read(fd, buf, bufsize);
        if(n <= 0)
            goto done;
        rc = entrySeek(entry, entry->body_offset + offset);
        if(rc < 0)
            goto done;
        rc = write(entry->fd, buf, n);
        if(rc >= 0) {
            entry->offset += rc;
            entry->size += rc;
        }
        if(rc < n)
            goto done;
    }
...

If a time event arrives during the while loop, the read/write could return
with errno EINTR, unless this function is only used for task that don't
require eventloop, such as truncate cache files.

Regards,
Ming
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Polipo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/polipo-users

Reply via email to