From 5fdda1a5891f8828075225975fbdef1d3e87fb57 Mon Sep 17 00:00:00 2001 From: Alexey Tikhonov Date: Mon, 11 Mar 2024 20:46:09 +0100 Subject: [PATCH] Merge pull request from GHSA-mg26-v6qh-x48q Backported from https://github.com/c-ares/c-ares/commit/a804c04ddc8245fc8adf0e92368709639125e183 --- ares__read_line.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ares__read_line.c b/ares__read_line.c index c62ad2a..d6625a3 100644 --- a/ares__read_line.c +++ b/ares__read_line.c @@ -49,6 +49,14 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize) if (!fgets(*buf + offset, bytestoread, fp)) return (offset != 0) ? 0 : (ferror(fp)) ? ARES_EFILE : ARES_EOF; len = offset + strlen(*buf + offset); + + /* Probably means there was an embedded NULL as the first character in + * the line, throw away line */ + if (len == 0) { + offset = 0; + continue; + } + if ((*buf)[len - 1] == '\n') { (*buf)[len - 1] = 0; -- 2.42.0