[CVE-2021-36976] tar: demote -xa from error to a warning 05/275105/2 accepted/tizen_7.0_base accepted/tizen_7.0_base_hotfix accepted/tizen_7.0_base_tool accepted/tizen_7.0_base_tool_hotfix tizen_7.0_base_hotfix accepted/tizen/7.0/base/20230714.002935 accepted/tizen/7.0/base/hotfix/20230714.003750 accepted/tizen/7.0/base/tool/20221028.121656 accepted/tizen/7.0/base/tool/hotfix/20221115.090233 accepted/tizen/base/tool/20220517.015812 accepted/tizen/base/tool/20220531.054653 submit/tizen_7.0_base/20221028.201101 submit/tizen_7.0_base_hotfix/20221115.161601 submit/tizen_base/20220517.015416 submit/tizen_base/20220518.221841 submit/tizen_base/20220518.221859 submit/tizen_base/20220524.054657 tizen_7.0_m2_release
authorEmil Velikov <emil.l.velikov@gmail.com>
Sun, 21 Nov 2021 18:05:19 +0000 (18:05 +0000)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 17 May 2022 00:02:21 +0000 (09:02 +0900)
It's fairly common for people to use caf and xaf on Linux. The former in
itself being GNU tar specific - libarchive tar does not allow xa.

While it makes little sense to use xaf with libarchive tar, that is
implementation detail which gets in the way when trying to write trivial
tooling/scripts.

For the sake of compatibility, reduce the error to a warning and augment
the message itself. Making it clear that the option makes little sense.

Change-Id: I9bac904eb133d82e6daf4bc20fbf5ff7a671d30c
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
tar/bsdtar.c

index af41be5..f4f008b 100644 (file)
@@ -796,8 +796,14 @@ main(int argc, char **argv)
                    "Must specify one of -c, -r, -t, -u, -x");
 
        /* Check boolean options only permitted in certain modes. */
-       if (bsdtar->flags & OPTFLAG_AUTO_COMPRESS)
-               only_mode(bsdtar, "-a", "c");
+       if (bsdtar->flags & OPTFLAG_AUTO_COMPRESS) {
+               only_mode(bsdtar, "-a", "cx");
+               if (bsdtar->mode == 'x') {
+                       bsdtar->flags &= ~OPTFLAG_AUTO_COMPRESS;
+                       lafe_warnc(0,
+                           "Ignoring option -a in mode -x");
+               }
+       }
        if (bsdtar->readdisk_flags & ARCHIVE_READDISK_NO_TRAVERSE_MOUNTS)
                only_mode(bsdtar, "--one-file-system", "cru");
        if (bsdtar->flags & OPTFLAG_FAST_READ)