From: Florian Forster Date: Wed, 24 Jul 2013 11:44:56 +0000 (+0200) Subject: src/ros.c: Check the return value of fgets(). X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ba77bd446bf69360905d1028f5d1a164208088d3;p=routeros-api.git src/ros.c: Check the return value of fgets(). Some compilers are unhappy when this return value is ignored. --- diff --git a/src/ros.c b/src/ros.c index 605c6b7..1d638b6 100644 --- a/src/ros.c +++ b/src/ros.c @@ -243,7 +243,12 @@ static char *read_password (void) /* {{{ */ return (NULL); } - fgets (buffer, sizeof (buffer), tty); + if (fgets (buffer, sizeof (buffer), tty) == NULL) + { + fprintf (stderr, "fgets failed: %s\n", strerror (errno)); + fclose (tty); + return (NULL); + } buffer[sizeof (buffer) - 1] = 0; buffer_len = strlen (buffer);