cipher: Fix possible NULL dereference.
authorWerner Koch <wk@gnupg.org>
Tue, 15 Apr 2014 14:40:48 +0000 (16:40 +0200)
committerWerner Koch <wk@gnupg.org>
Tue, 15 Apr 2014 20:15:11 +0000 (22:15 +0200)
* cipher/md.c (_gcry_md_selftest): Check for spec being NULL.
--

Also removed left-over code in unused file cipher/test-getrusage.c.

Found by Hans-Christoph Steiner with cppcheck.

cipher/md.c
cipher/test-getrusage.c

index 461ad64..5ab89cb 100644 (file)
@@ -1250,7 +1250,8 @@ _gcry_md_selftest (int algo, int extended, selftest_report_func_t report)
     ec = spec->selftest (algo, extended, report);
   else
     {
-      ec = spec->selftest? GPG_ERR_DIGEST_ALGO : GPG_ERR_NOT_IMPLEMENTED;
+      ec = (spec && spec->selftest) ? GPG_ERR_DIGEST_ALGO
+        /* */                       : GPG_ERR_NOT_IMPLEMENTED;
       if (report)
         report ("digest", algo, "module",
                 (spec && !spec->flags.disabled)?
index 6fc8372..7f586dd 100644 (file)
@@ -45,10 +45,6 @@ main (int argc, char **argv)
   printf ("ru_nvcsw   = %ld\n", buf.ru_nvcsw    );
   printf ("ru_nivcsw  = %ld\n", buf.ru_nivcsw   );
 
-  fprintf (stderr, "ru_utime   ru_stime   ru_minflt  ru_nccsw  ru_nivcsw\n");
-  fprintf (stderr, "%ld.%06ld  %ld.%06ld  %5ld       %5ld      %5ld\n");
-
-
   return 0;
 }