Skip to content

Commit

Permalink
Remove getline and replace with fgets
Browse files Browse the repository at this point in the history
This is to restore compatability with Mac OS X <= 10.6

Update CHANGES and AUTHORS
  • Loading branch information
David Adrian committed May 24, 2013
1 parent e8aa8c7 commit 5ef4cbc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ Dug Song <dugsong@duosecurity.com>
S. Zachariah Sprackett <zac@sprackett.com>
duo_unix.spec

David Adrian <davidadrian@duosecurity.com>
various config options

Adam Goodman <akgood@duosecurity.com>
repairing what David fixed
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
duo_unix-1.9.2:

- Restore compatability with Mac OS X <= 10.6

duo_unix-1.9.1:

- Add motd option to the config file
Expand Down
15 changes: 5 additions & 10 deletions login_duo/login_duo.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,10 @@ _print_motd()
FILE *fp;
struct stat st;
int fd, bytes_read;
size_t nbytes = 80;
char *line;
size_t nbytes = 81;
char read[nbytes];
char *result;

if ((line = (char *) malloc(nbytes + 1)) == NULL) {
fprintf(stderr, "Out of memory printing MOTD\n");
return (-1);
}
if ((fd = open(MOTD_FILE, O_RDONLY)) < 0 ) {
return (-1);
}
Expand All @@ -205,11 +202,9 @@ _print_motd()
return (-1);
}

while ((bytes_read = getline(&line, &nbytes, fp)) > 0) {
printf("%s", line);
while ((result = fgets(read, nbytes, fp))) {
printf("%s", result);
}
free(line);
line = NULL;
return (0);
}

Expand Down

0 comments on commit 5ef4cbc

Please sign in to comment.