[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r3735 - trunk/OpenDNSSEC/libhsm/src

Jakob Schlyter jakob at kirei.se
Wed Aug 11 13:19:24 CEST 2010


Author: jakob
Date: 2010-08-11 13:19:24 +0200 (Wed, 11 Aug 2010)
New Revision: 3735

Modified:
   trunk/OpenDNSSEC/libhsm/src/hsmutil.c
Log:
safer fgets(3) for purge confirmation

Modified: trunk/OpenDNSSEC/libhsm/src/hsmutil.c
===================================================================
--- trunk/OpenDNSSEC/libhsm/src/hsmutil.c	2010-08-11 11:18:06 UTC (rev 3734)
+++ trunk/OpenDNSSEC/libhsm/src/hsmutil.c	2010-08-11 11:19:24 UTC (rev 3735)
@@ -251,6 +251,7 @@
 {
     int result;
     int final_result = 0;
+    char *fresult;
 
     size_t i;
     char *repository = NULL;
@@ -290,8 +291,8 @@
     }
 
     printf("Are you sure you want to remove ALL keys from repository %s ? (YES/NO) ", repository);
-    fgets(confirm, sizeof(confirm) - 1, stdin);
-    if (strncasecmp(confirm, "yes", 3) != 0) {
+    fresult = fgets(confirm, sizeof(confirm) - 1, stdin);
+    if (fresult == NULL || strncasecmp(confirm, "yes", 3) != 0) {
         printf("\nPurge cancelled.\n");
         hsm_key_list_free(keys, key_count);
         return -1;




More information about the Opendnssec-commits mailing list