]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Set an error message for setting invalid format by code on readers 1404/head
authorYichao Yu <yyc1992@gmail.com>
Sun, 28 Jun 2020 15:29:45 +0000 (11:29 -0400)
committerYichao Yu <yyc1992@gmail.com>
Sun, 28 Jun 2020 15:32:31 +0000 (11:32 -0400)
The error message is consistent with `archive_read_set_format`.
The absense of an error message here also means that the error message
in `archive_read_set_format` is actually never used.

Writer functions does not seem to have the same issue.

libarchive/archive_read_support_format_by_code.c

index 034353d78f63980eef97969baafcf6d6405ec79f..81ab770ade3d02cd5ffbf41c92f9db80cc8f0d78 100644 (file)
 #include "archive_platform.h"
 __FBSDID("$FreeBSD$");
 
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
 #include "archive.h"
 #include "archive_private.h"
 
@@ -73,5 +77,7 @@ archive_read_support_format_by_code(struct archive *a, int format_code)
                return archive_read_support_format_zip(a);
                break;
        }
+       archive_set_error(a, ARCHIVE_ERRNO_PROGRAMMER,
+           "Invalid format code specified");
        return (ARCHIVE_FATAL);
 }