Home GnuPG
Diffusion GnuPG 628b111fa679

avoid double-close in unusual dotlock situations
628b111fa679Unpublished

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

avoid double-close in unusual dotlock situations

* common/dotlock.c: (dotlock_create_unix) avoid double-close()
 in unusual situations.

close(2) says:

close() should not be retried after an EINTR since this may

cause a reused descriptor from another thread to be closed.

Before this patch was applied, if close(fd) failed with EINTR, it
would be closed again in the write_failed: block.

It could also have been closed a second time in the case that
(use_hardlinks_p (h->tname)) evaluated to something other than 0 or 1.

This patch avoids both of those scenarios.

Note that close() could still be called twice on the same file
descriptor if the first close(fd) fails but errno is not EINTR. I'm
not sure the right thing to do in that scenario. An alternate
resolution could be to unequivocally set fd to -1 after the first
failed close(fd), avoiding the errno == EINTR test.

Details

Provenance
dkgAuthored on Dec 19 2014, 11:12 PM
wernerCommitted on Dec 22 2014, 12:56 PM
Parents
rG351bca9047d7: gpgkey2ssh: clean up varargs
Branches
Unknown
Tags
Unknown

Event Timeline

Werner Koch <wk@gnupg.org> committed rG628b111fa679: avoid double-close in unusual dotlock situations (authored by Daniel Kahn Gillmor <dkg@fifthhorseman.net>).Dec 22 2014, 12:56 PM