[Bug 815] New: SEGFAULT in archival/tar.c found

bugzilla at busybox.net bugzilla at busybox.net
Thu Dec 17 21:33:10 UTC 2009


              Host: powerpc-gnu-linux-uclibc
            Target: powerpc-gnu-linux-uclibc
             Build: powerpc-gnu-linux-uclibc
           Summary: SEGFAULT in archival/tar.c found
           Product: Busybox
           Version: 1.16.x
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: trivial
          Priority: P2
         Component: Standard Compliance
        AssignedTo: unassigned at busybox.net
        ReportedBy: dougmencken at gmail.com
                CC: busybox-cvs at busybox.net
   Estimated Hours: 0.0

How to reproduce:
just 'tar' (yep, it must be busybox's tar)

What you'll get:
a segfault

The fix is trivial; all you need is *not* to argv[1][0] int tar_main(int argc,
char **argv) w/o any knowledge of number of arguments passed.

The working version is:

int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tar_main(int argc, char **argv)
        char FAST_FUNC (*get_header_ptr)(archive_handle_t *) = get_header_tar;
        archive_handle_t *tar_handle;
        char *base_dir = NULL;
        const char *tar_filename = "-";
        unsigned opt;
        int verboseFlag = 0;
        llist_t *excludes = NULL;

        /* Initialise default values */
        tar_handle = init_handle();
        tar_handle->ah_flags = ARCHIVE_CREATE_LEADING_DIRS
                             | ARCHIVE_RESTORE_DATE
                             | ARCHIVE_UNLINK_OLD;

        /* Apparently only root's tar preserves perms (see bug 3844) */
        if (getuid() != 0)
                tar_handle->ah_flags |= ARCHIVE_DONT_RESTORE_PERM;

        /* Prepend '-' to the first argument if required */
        opt_complementary = "--:" // first arg is options
                "tt:vv:" // count -t,-v
                "?:" // bail out with usage instead of error return
                "X::T::" // cumulative lists
                "\xff::" // cumulative lists for --exclude
                IF_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is
                IF_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually
                IF_NOT_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
        applet_long_options = tar_longopts;
        if ((argc > 1) && (argv[1][0] != '-')) {
                /* Compat:
                 * 1st argument without dash handles options with parameters

Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the busybox-cvs mailing list