From b9d627b9602137eb1bb98ebb6801c97b0ad33e43 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 12 Jan 2023 22:05:58 +0100 Subject: libfonts_parse_dir_line: do not allow / in file name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libfonts_parse_dir_line.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'libfonts_parse_dir_line.c') diff --git a/libfonts_parse_dir_line.c b/libfonts_parse_dir_line.c index a339ce3..de14ea9 100644 --- a/libfonts_parse_dir_line.c +++ b/libfonts_parse_dir_line.c @@ -4,22 +4,25 @@ static int -read_field(char **valuep, int allow_blank, const char *s, const char **endp) +read_field(char **valuep, int fieldno, const char *s, const char **endp) { - char endc; + char endc, slash; size_t esc = 0; size_t len; const char *start; const char *end; char *v; + if (fieldno == 0) { + endc = ' '; + slash = '/'; + } else { + endc = '\n'; + slash = '\0'; + } if (*s == '"') { endc = '"'; s++; - } else if (allow_blank) { - endc = '\n'; - } else { - endc = ' '; } start = s; @@ -32,6 +35,8 @@ read_field(char **valuep, int allow_blank, const char *s, const char **endp) if (!*s || *s == '\n') goto badline; } + if (*s == slash) + goto badline; s++; } end = s; -- cgit v1.2.3-70-g09d2