]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix unchecked strdup result in __archive_write_program_allocate
authorTim Kientzle <kientzle@acm.org>
Sat, 16 May 2026 17:04:38 +0000 (10:04 -0700)
committerTim Kientzle <kientzle@acm.org>
Sat, 16 May 2026 17:04:38 +0000 (10:04 -0700)
If strdup fails, program_name would be NULL and later use could crash.
Free data and return NULL on allocation failure.

libarchive/archive_write_add_filter_program.c

index f12db33738833d1b85de1e45ac41702e553719e7..cb92dc04f0d10532f1d9932b290ffb29b4bc7b63 100644 (file)
@@ -184,6 +184,10 @@ __archive_write_program_allocate(const char *program)
        data->child_stdin = -1;
        data->child_stdout = -1;
        data->program_name = strdup(program);
+       if (data->program_name == NULL) {
+               free(data);
+               return (NULL);
+       }
        return (data);
 }