]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xzdec: Call tuklib_progname_init() early enough
authorLasse Collin <lasse.collin@tukaani.org>
Wed, 18 Dec 2024 12:12:22 +0000 (14:12 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Wed, 18 Dec 2024 17:22:00 +0000 (19:22 +0200)
If the early pledge() call on OpenBSD fails, it calls my_errorf()
which requires the "progname" variable.

Fixes: d74fb5f060b76db709b50f5fd37490394e52f975
(cherry picked from commit 4e936f234056e5831013ed922145b666b04bb1e3)

src/xzdec/xzdec.c

index a75ea42a52fb0a535efd5b82bfe08dbbcabb31cb..49d47bb220980665b3b1974b7633de2913ed4a2f 100644 (file)
@@ -391,6 +391,9 @@ error:
 int
 main(int argc, char **argv)
 {
+       // Initialize progname which we will be used in error messages.
+       tuklib_progname_init(argv);
+
 #ifdef HAVE_PLEDGE
        // OpenBSD's pledge(2) sandbox.
        // Initially enable the sandbox slightly more relaxed so that
@@ -416,9 +419,6 @@ main(int argc, char **argv)
        (void)prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
 #endif
 
-       // Initialize progname which we will be used in error messages.
-       tuklib_progname_init(argv);
-
        // Parse the command line options.
        parse_options(argc, argv);