Skip to content

Commit 3f4e66c

Browse files
committed
tests: certificate: fix fgets warning
1 parent 8876a13 commit 3f4e66c

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/test-certificate/test-certificate.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ int main () {
1919
#include <pkcs11-helper-1.0/pkcs11h-certificate.h>
2020
#include <unistd.h>
2121

22+
static
23+
void
24+
fatal0 (const char * const m) {
25+
fprintf (stderr, "%sn", m);
26+
exit (1);
27+
}
28+
2229
static
2330
void
2431
fatal (const char * const m, CK_RV rv) {
@@ -33,7 +40,9 @@ mypause (const char * const m) {
3340

3441
fprintf (stdout, "%s", m);
3542
fflush (stdout);
36-
fgets (temp, sizeof (temp), stdin);
43+
if (fgets (temp, sizeof (temp), stdin) == NULL) {
44+
fatal0("fgets failed");
45+
}
3746
}
3847

3948
static
@@ -63,7 +72,9 @@ _pkcs11h_hooks_token_prompt (
6372

6473
while (!fValidInput) {
6574
fprintf (stderr, "Please insert token '%s' 'ok' or 'cancel': ", token->display);
66-
fgets (buf, sizeof (buf), stdin);
75+
if (fgets (buf, sizeof (buf), stdin) == NULL) {
76+
fatal0("fgets failed");
77+
}
6778
buf[sizeof (buf)-1] = '\0';
6879
fflush (stdin);
6980

0 commit comments

Comments
 (0)