From: Yichao Yu Date: Sun, 28 Jun 2020 15:29:45 +0000 (-0400) Subject: Set an error message for setting invalid format by code on readers X-Git-Tag: v3.5.0~24^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2778b7e7026038313c55935808a0d5a68db1f72a;p=thirdparty%2Flibarchive.git Set an error message for setting invalid format by code on readers 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. --- diff --git a/libarchive/archive_read_support_format_by_code.c b/libarchive/archive_read_support_format_by_code.c index 034353d78..81ab770ad 100644 --- a/libarchive/archive_read_support_format_by_code.c +++ b/libarchive/archive_read_support_format_by_code.c @@ -26,6 +26,10 @@ #include "archive_platform.h" __FBSDID("$FreeBSD$"); +#ifdef HAVE_ERRNO_H +#include +#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); }