cipher: Fix a segv in case of calling with wrong parameters.
authorWerner Koch <wk@gnupg.org>
Thu, 21 Aug 2014 09:47:16 +0000 (11:47 +0200)
committerWerner Koch <wk@gnupg.org>
Thu, 21 Aug 2014 10:22:37 +0000 (12:22 +0200)
* cipher/md.c (_gcry_md_info): Fix arg testing.
--

GnuPG-bug-id: 1697

cipher/md.c

index a1e5859..df8b027 100644 (file)
@@ -1181,7 +1181,7 @@ _gcry_md_info (gcry_md_hd_t h, int cmd, void *buffer, size_t *nbytes)
        GcryDigestEntry *r;
        int algo;
 
-       if ( !buffer || (nbytes && (*nbytes != sizeof (int))))
+       if ( !buffer || !nbytes || *nbytes != sizeof (int))
          rc = GPG_ERR_INV_ARG;
        else
          {