summaryrefslogtreecommitdiffstats
path: root/lib/libstand/gets.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libstand/gets.c')
-rw-r--r--lib/libstand/gets.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/libstand/gets.c b/lib/libstand/gets.c
index 3fbe9b4..dc26a99 100644
--- a/lib/libstand/gets.c
+++ b/lib/libstand/gets.c
@@ -95,8 +95,11 @@ fgetstr(char *buf, int size, int fd)
err = read(fd, &c, sizeof(c));
if (err < 0) /* read error */
return(-1);
- if (err == 0) /* EOF */
+ if (err == 0) { /* EOF */
+ if (len == 0)
+ return(-1); /* nothing to read */
break;
+ }
if ((c == '\r') || /* line terminators */
(c == '\n'))
break;
OpenPOWER on IntegriCloud