Skip to content

Commit

Permalink
Replace getline() by fgets() because the former doesn't exist in Sola…
Browse files Browse the repository at this point in the history
…ris <11

Fixes google#537
  • Loading branch information
ThomasHabets committed Feb 1, 2016
1 parent 775a202 commit c0404dc
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions libpam/google-authenticator.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,32 +316,25 @@ static void displayQRCode(const char *secret, const char *label,
static int maybe(const char *msg) {
printf("\n");
for (;;) {
char* line = NULL;
size_t len = 0;
char line[128];
printf("%s (y/n) ", msg);
fflush(stdout);

if (0 > getline(&line, &len, stdin)) {
line[sizeof(line)-1] = 0;
if (NULL == fgets(line, sizeof(line), stdin)) {
if (errno == 0) {
printf("\n");
} else {
perror("getline()");
}
exit(1);
}
if (len < 1) {
free(line);
continue;
}

switch (line[0]) {
case 'Y':
case 'y':
free(line);
return 1;
case 'N':
case 'n':
free(line);
return 0;
}
}
Expand Down

0 comments on commit c0404dc

Please sign in to comment.