From: tb Date: Wed, 28 Dec 2022 12:16:35 +0000 (+0000) Subject: Properly ignore comments in geofeed files X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d313d8cd45e3a3a61a43c1615876def91c3c6e9d;p=openbsd Properly ignore comments in geofeed files Do not consider comments and whitespace leading up to a comment as part of the line. ok claudio job --- diff --git a/usr.sbin/rpki-client/geofeed.c b/usr.sbin/rpki-client/geofeed.c index ef28b033b04..e989d808d90 100644 --- a/usr.sbin/rpki-client/geofeed.c +++ b/usr.sbin/rpki-client/geofeed.c @@ -1,4 +1,4 @@ -/* $OpenBSD: geofeed.c,v 1.8 2022/12/14 10:45:34 job Exp $ */ +/* $OpenBSD: geofeed.c,v 1.9 2022/12/28 12:16:35 tb Exp $ */ /* * Copyright (c) 2022 Job Snijders * Copyright (c) 2019 Kristaps Dzonsons @@ -16,6 +16,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include #include @@ -192,14 +193,19 @@ geofeed_parse(X509 **x509, const char *fn, char *buf, size_t len) goto out; } - /* Skip empty lines or commented lines. */ - if (linelen == 0 || line[0] == '#') - continue; - - /* zap comments */ + /* Zap comments and whitespace before them. */ delim = memchr(line, '#', linelen); - if (delim != NULL) + if (delim != NULL) { + while (delim > line && + isspace((unsigned char)delim[-1])) + delim--; *delim = '\0'; + linelen = delim - line; + } + + /* Skip empty lines. */ + if (linelen == 0) + continue; /* Split prefix and location info */ delim = memchr(line, ',', linelen);