[pacman-dev] [PATCH] Fix double close of the lock file
jonno.conder at gmail.com
Sun Feb 27 03:59:13 EST 2011
On 5 February 2011 13:39, Jonathan Conder <jonno.conder at gmail.com> wrote:
> According to FOPEN(3), using fclose on an fdopen'd file stream also
> closes the underlying file descriptor. This happened in _alpm_lckmk
> (util.c), which meant that when alpm_trans_release closed it again, the
> log file (which reused the original file descriptor) was closed instead.
I wrote a small test case for this in order to better explain the bug. You
can compile it with
gcc test.c -o test -Wall -pedantic -lalpm
It will create a log file at /tmp/pacman.log and can be run without root
privileges. The expected contents of this log should be two lines, as you
can probably tell from the source. However, without my patch the second line
is not logged.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 481 bytes
Desc: not available
More information about the pacman-dev