From: Rose Date: Sat, 17 May 2025 23:35:22 +0000 (-0400) Subject: Fatal if field[0].start or field[0].end is null X-Git-Tag: v3.8.0~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2612%2Fhead;p=thirdparty%2Flibarchive.git Fatal if field[0].start or field[0].end is null We should not get here, but given that the check exists, we should not let it happen if this is NULL because otherwise we just dereference it later on. --- diff --git a/libarchive/archive_acl.c b/libarchive/archive_acl.c index bbb085afe..9e71f5ee5 100644 --- a/libarchive/archive_acl.c +++ b/libarchive/archive_acl.c @@ -1185,8 +1185,13 @@ archive_acl_from_text_w(struct archive_acl *acl, const wchar_t *text, /* Set remaining fields to blank. */ for (n = fields; n < numfields; ++n) field[n].start = field[n].end = NULL; + + if (field[0].start == NULL || field[0].end == NULL) { + /* This should never happen */ + return (ARCHIVE_FATAL); + } - if (field[0].start != NULL && *(field[0].start) == L'#') { + if (*(field[0].start) == L'#') { /* Comment, skip entry */ continue; } @@ -1676,7 +1681,12 @@ archive_acl_from_text_nl(struct archive_acl *acl, const char *text, for (n = fields; n < numfields; ++n) field[n].start = field[n].end = NULL; - if (field[0].start != NULL && *(field[0].start) == '#') { + if (field[0].start == NULL || field[0].end == NULL) { + /* This should never happen */ + return (ARCHIVE_FATAL); + } + + if (*(field[0].start) == '#') { /* Comment, skip entry */ continue; }