]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fatal if field[0].start or field[0].end is null 2612/head
authorRose <gfunni234@gmail.com>
Sat, 17 May 2025 23:35:22 +0000 (19:35 -0400)
committerRose <gfunni234@gmail.com>
Mon, 19 May 2025 18:35:45 +0000 (14:35 -0400)
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.

libarchive/archive_acl.c

index bbb085afe7afa8615f5a0a0ff1482537d7167938..9e71f5ee561090c214f7d3b7120cc969b366119c 100644 (file)
@@ -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;
                }