aboutgitcodebugslistschat
path: root/util.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-20 11:39:08 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-20 11:39:08 +0200
commita20626fb3516169c8c06bd1729cf29465d2cbd1f (patch)
tree8f4759a2a5c26fac14c9eec818fd84372250c937 /util.c
parent9618d247006a41fba5c1b0470e4723196f96b424 (diff)
downloadpasst-a20626fb3516169c8c06bd1729cf29465d2cbd1f.tar
passt-a20626fb3516169c8c06bd1729cf29465d2cbd1f.tar.gz
passt-a20626fb3516169c8c06bd1729cf29465d2cbd1f.tar.bz2
passt-a20626fb3516169c8c06bd1729cf29465d2cbd1f.tar.lz
passt-a20626fb3516169c8c06bd1729cf29465d2cbd1f.tar.xz
passt-a20626fb3516169c8c06bd1729cf29465d2cbd1f.tar.zst
passt-a20626fb3516169c8c06bd1729cf29465d2cbd1f.zip
util: Go to next non-empty line, skip newlines in line_read()
Otherwise, we'll stop returning lines at the first empty line in a file -- this is not expected in case of e.g. /etc/resolv.conf. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
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;