diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-10-20 11:39:08 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-10-20 11:39:08 +0200 |
commit | a20626fb3516169c8c06bd1729cf29465d2cbd1f (patch) | |
tree | 8f4759a2a5c26fac14c9eec818fd84372250c937 /util.c | |
parent | 9618d247006a41fba5c1b0470e4723196f96b424 (diff) | |
download | passt-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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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; |