Bug#773474: [PATCH] * scd/app-openpgp.c: (get_public_key) correctly close 'fp' upon use.

Werner Koch wk at gnupg.org
Wed Jan 7 09:22:46 CET 2015


On Wed,  7 Jan 2015 01:20, gniibe at fsij.org said:
> On 12/20/2014 09:38 AM, Joshua Rogers wrote:
>> Inside the get_public_key function, 'fp' was opened using popen, but incorrectly closed using fclose.

> Thank you for your patch.  Good catch.

Yeah. After 9 years or so :-).

But there is a portability problem.  From libgcrypt's rndunix.c:

/* Under SunOS popen() doesn't record the pid of the child process.  When
 * pclose() is called, instead of calling waitpid() for the correct child, it
 * calls wait() repeatedly until the right child is reaped.  The problem is
 * that this reaps any other children that happen to have died at that
 * moment, and when their pclose() comes along, the process hangs forever.
 * The fix is to use a wrapper for popen()/pclose() which saves the pid in
 * the dataSources structure (code adapted from GNU-libc's popen() call).
 *
 * Aut viam inveniam aut faciam */

scdaemon may also start other processes (status scripts) and there is a
chance that the above described bug would be triggered.  However, I do
not know up to which SunOS version the problem exists and whether anyone
is using the really old 1.0 card on SunOS.

Thus the fix is better than keeping it as it is.


Shalom-Salam,

   Werner


-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.




More information about the Gnupg-devel mailing list