]> err.no Git - yubikey-personalization/commitdiff
Check return code from fgets to silence warnings.
authorSimon Josefsson <simon@josefsson.org>
Thu, 4 Apr 2013 10:18:32 +0000 (12:18 +0200)
committerSimon Josefsson <simon@josefsson.org>
Thu, 4 Apr 2013 10:18:32 +0000 (12:18 +0200)
ykpersonalize.c

index 3491c7e5ced299c3a3a3ae4c2dda09344fc19f1d..c2755000b1b4e140f234d1d51662c83ff06f3171 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- mode:C; c-file-style: "bsd" -*- */
 /*
- * Copyright (c) 2008-2012 Yubico AB
+ * Copyright (c) 2008-2013 Yubico AB
  * Copyright (c) 2010 Tollef Fog Heen <tfheen@err.no>
  * All rights reserved.
  *
@@ -187,7 +187,12 @@ int main(int argc, char **argv)
                char passphrasebuf[256]; size_t passphraselen;
                fprintf(stderr, "Passphrase to create AES key: ");
                fflush(stderr);
-               fgets(passphrasebuf, sizeof(passphrasebuf), stdin);
+               if (!fgets(passphrasebuf, sizeof(passphrasebuf), stdin))
+               {
+                       perror ("fgets");
+                       exit_code = 1;
+                       goto err;
+               }
                passphraselen = strlen(passphrasebuf);
                if (passphrasebuf[passphraselen - 1] == '\n')
                        passphrasebuf[passphraselen - 1] = '\0';
@@ -225,7 +230,12 @@ int main(int argc, char **argv)
                        strcpy(commitbuf, "yes");
                        puts(commitbuf);
                } else {
-                       fgets(commitbuf, sizeof(commitbuf), stdin);
+                       if (!fgets(commitbuf, sizeof(commitbuf), stdin))
+                       {
+                               perror ("fgets");
+                               exit_code;
+                               goto err;
+                       }
                }
                commitlen = strlen(commitbuf);
                if (commitbuf[commitlen - 1] == '\n')