[Top][All Lists]

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

Re: [Bug-wget] [PATCH] Update HSTS info

From: Ander Juaristi
Subject: Re: [Bug-wget] [PATCH] Update HSTS info
Date: Thu, 08 Oct 2015 20:22:46 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0

Hi Tim,

Thanks for your comments. I re-send the first patch. No changes on the second.

On 10/08/2015 10:37 AM, Tim Ruehsen wrote:
+          flock (fd, LOCK_UN);
+          fclose (f);
You are using buffered I/O, fclose() is effectively a write() + close().
That opens a hole here if you unlock the file before write().
IMO, to avoid that hole you could just drop the explicit unlock. It will be
performed automatically when the file is closed by fclose().

You were right, the lock is released by fclose(). Obvious, isn't it? I mean, 
that's what one would expect.

I thought about this but I wasn't really sure. The docs are not 100% clear IMO:

    "Furthermore, the lock is released either by an explicit LOCK_UN operation 
on any of these  duplicate  descriptors,
     or when all such descriptors have been closed."

- AJ

Attachment: 0001-Fix-potential-race-condition.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]