aboutgitcodebugslistschat
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/util.c b/util.c
index 4c2e9bb..6fb535c 100644
--- a/util.c
+++ b/util.c
@@ -405,7 +405,11 @@ char *line_read(char *buf, size_t len, int fd)
buf[len] = 0;
- if (!(p = strchr(buf, '\n')))
+ p = buf;
+ while (*p == '\n' && strlen(p) && (size_t)(p - buf) < len)
+ p++;
+
+ if (!(p = strchr(p, '\n')))
return buf;
*p = 0;