mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-23 20:08:04 +01:00
Avoid double-close in unusual dotlock situations.
* jnlib/dotlock.c (create_dotlock): Avoid double close due to EINTR. -- close(2) says: close() should not be retried after an EINTR since this may cause a reused descriptor from another thread to be closed. (backported from commit 628b111fa679612e23c0d46505b1ecbbf091897d) Debian-Bug-Id: 773423 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
b2359db21c
commit
f256bab03e
@ -244,7 +244,12 @@ create_dotlock (const char *file_to_lock)
|
||||
if ( write (fd, "\n", 1 ) != 1 )
|
||||
goto write_failed;
|
||||
if ( close (fd) )
|
||||
goto write_failed;
|
||||
{
|
||||
if ( errno == EINTR )
|
||||
fd = -1;
|
||||
goto write_failed;
|
||||
}
|
||||
fd = -1;
|
||||
|
||||
# ifdef _REENTRANT
|
||||
/* release mutex */
|
||||
@ -267,7 +272,8 @@ create_dotlock (const char *file_to_lock)
|
||||
/* fixme: release mutex */
|
||||
# endif
|
||||
log_error ( _("error writing to `%s': %s\n"), h->tname, strerror(errno) );
|
||||
close (fd);
|
||||
if (fd != -1)
|
||||
close (fd);
|
||||
unlink (h->tname);
|
||||
jnlib_free (h->tname);
|
||||
jnlib_free (h);
|
||||
|
Loading…
x
Reference in New Issue
Block a user