1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Snow Leopard breaks tar: corrupted octal value in tar header

Discussion in 'Tomato Firmware' started by Planiwa, Sep 18, 2009.

  1. Planiwa

    Planiwa LI Guru Member

    Tomato Fails to Extract Tar File from Snow Leopard

    Tomato's BusyBox tar program cannot read Mac OS X v10.6 tar files!!!
    Error Message: "tar: corrupted octal value in tar header"

    Interested readers with access to GNU/Linux 2.4 systems (other than Tomato) may want to unzip the attached file, to get snow.tar, and then run

    tar -tvf snow.tar

    and report if it fails, and with which error.

    Such reports will help determine whether the problem lies with ...

    Linux 2.4.20
    BusyBox v1.14.2
    Tomato's BusyBox config
    Apple's changes to tar format in Snow Leopard Mac OS X 10.6.

    Attached Files:

    • snow.zip
      File size:
      274 bytes
  2. Elbart

    Elbart LI Guru Member

    Why should Tomato be able to handle tarballs?
  3. Assman

    Assman Addicted to LI Member

  4. occamsrazor

    occamsrazor Network Guru Member

    I have 10.6 and Tomato... but can't for the life of me work out what you guys are talking about. Can someone explain a bit more clearly what the alleged problem is?
  5. Elbart

    Elbart LI Guru Member

    I made a TAR with the latest stable 7-zip (Mista x68 SP2), and BusyBox of 1.25 won't eat it either.
    "tar: invalid tar magic"

    Then I made the same TAR with a Win32-compile from here, which worked.
    I guess BusyBox is very picky about that.
  6. mstombs

    mstombs Network Guru Member

    Just happen to have a test ADSL Router code running Linux 2.4.17Ti, looks like a BB bug

  7. Planiwa

    Planiwa LI Guru Member

    While I am no fan of BusyBugs in general -- I consider it a deeply flawed concept -- and while I am not particularly fond of the particular code, terminology, and error message text involved, it appears that this problem is the result of misconfigurations by (some?) Tomato developers.

    This is from the busybox .config file from victek/Tomato/Tomato_RAF_1.25.8515.2_Source_Code

    # CONFIG_FEATURE_TAR_FROM is not set
    Snow Leopard, "The World's most advanced OS", has switched to the POSIX tar format, which according to BusyBox terminology requires "OLDGNU_COMPATIBILITY".

    No, it doesn't seem to make sense.

    The Tomato developers may wish to examine their .config files. Should contain:


    This just in from the BusyBox camp:

    Apple may have "reused" old code without examining it, and thus revived old quirks rather than moving beyond them.

    This would explain the pointless extra spaces, as well as the sudden need fo accommodate obsolete idiosyncrasies for the newest OS.
  8. Planiwa

    Planiwa LI Guru Member


    It turns out that this problem was a combination of the last 3 of the 4 posibilities that I had originally identified.

    I am happy to report that this problem has been resolved. Busybox has now been changed so that there is no longer a problem, regardless of the .config file and even if Apple continues to produce inconsistent (but legal) tar headers.

    Thanks to all who have helped to correct this problem before many people have even become aware of it.

    diff --git a/archival/libunarchive/get_header_tar.c b/archival/libunarchive/get_header_tar.c
    index 71e08bf..b8d7648 100644
    --- a/archival/libunarchive/get_header_tar.c
    +++ b/archival/libunarchive/get_header_tar.c
    @@ -87,11 +87,13 @@ static unsigned long long getOctal(char *str, int len)
     	unsigned long long v;
     	/* NB: leading spaces are allowed. Using strtoull to handle that.
    -	 * The downside is that we accept e.g. "-123" too :)
    +	 * The downside is that we accept e.g. "-123" too :(
     	str[len] = '\0';
     	v = strtoull(str, &str, 8);
    -	if (*str && (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY || *str != ' '))
    +	/* std: "Each numeric field is terminated by one or more
    +	 * <space> or NUL characters". We must support ' '! */
    +	if (*str != '\0' && *str != ' ')
     		bb_error_msg_and_die("corrupted octal value in tar header");
     	return v;
    @@ -262,20 +264,20 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
     		sum_s += ((signed char*)&tar)[i];
    -	sum = strtoul(tar.chksum, &cp, 8);
    -	if ((*cp && *cp != ' ')
    -	 || (sum_u != sum IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum))
    -	) {
    -		bb_error_msg_and_die("invalid tar header checksum");
    -	}
     	/* This field does not need special treatment (getOctal) */
    +	{
    +		char *endp; /* gcc likes temp var for &endp */
    +		sum = strtoul(tar.chksum, &endp, 8);
    +		if ((*endp != '\0' && *endp != ' ')
    +		 || (sum_u != sum IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum))
    +		) {
    +			bb_error_msg_and_die("invalid tar header checksum");
    +		}
    +	}
     	sum = xstrtoul(tar.chksum, 8);
     	if (sum_u != sum IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum)) {
     		bb_error_msg_and_die("invalid tar header checksum");
     	/* 0 is reserved for high perf file, treat as normal file */
     	if (!tar.typeflag) tar.typeflag = '0';
    Postel's Prescription:
    "Be generous in what you accept, rigorous in what you emit."
  9. occamsrazor

    occamsrazor Network Guru Member

    I'm running Tomato (thor Mod) with a bunch of 10.6 SL machines. I don't really understand the details of what you guys have been discussing, but am glad you found an answer!

    My question is.... do I need to be worried about this? If so... will we need an update of the Tomato firmware to fix the problem?
  10. Planiwa

    Planiwa LI Guru Member

    All existing Tomato firmware potentially has this problem.
    I have only verified this for Victek's
    Others may or may not actually have the problem.

    Eventually, when the next release of BusyBox is out and incorported, none will have this probem.

    (Those with ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY do not have the problem.
    Eventually, this will not be required any more at all for anything.)

    In the meantime, if you want to know whether your Tomato has the problem,
    you can do what I suggested in my post #1, disregarding the words "other than".

    Of course, those who don't use tar in their Tomato shell won't encounter the problem,
    even if their tar has the problem.

Share This Page