chiark / gitweb /
gpg,common: Make sure that all fd given are valid.
[gnupg2.git] / g10 / passphrase.c
index fb4ec4c857ec39e9ac84a09726590ccc3a1f56c2..37abc0f1c766f6b7242aa987e3843921081632be 100644 (file)
@@ -166,6 +166,9 @@ read_passphrase_from_fd( int fd )
   int i, len;
   char *pw;
 
+  if (! gnupg_fd_valid (fd))
+    log_fatal ("passphrase-fd is invalid: %s\n", strerror (errno));
+
   if ( !opt.batch && opt.pinentry_mode != PINENTRY_MODE_LOOPBACK)
     { /* Not used but we have to do a dummy read, so that it won't end
          up at the begin of the message if the quite usual trick to