From: COLSA@wsmr-simtel20.army.mil (Larry Armijo)
Subject: Bug in GNU tar-1.11.1
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 19 Nov 1992 16:15:00 GMT

The following message was sent to me by a co-worker who does not
have access to the Internet.  It concerns a bug which he found and
fixed in GNU tar-1.11.1.  The problem occurs when GNU tar is used
in multivolume mode.  We hope this will be helpful to the maintainers
of the GNU utilities.  If there are any questions or suggestions,
send them to me and I will forward them to Greg.  We use GNU tar
as the primary backup tool for our unix systems.  These include
Silicon Graphics, Sun, Solborne, Encore, Alliant, iPSC and BBN
Butterfly computers.  The native compilers were used to compile
tar-1.11.1 from the source.  Greg's message follows:

-----------------------------------------------------------------

Return-Path: <browng@max01>
Date: Wed, 18 Nov 92 10:39:33 CST
From: Greg Brown <browng@max01>
To: larmijo@sun01



Hi Larry!

Below you will find a fix for the problem I encountered with the new version
of gtar.  At least, I hope that this is what the GNU people had in mind.
The modification which I made is at the bottom of the routine finish_header.

Description of problem:

When using the --label option, a null pointer was encountered by the routine
quote_copy_string, causing a core dump on some systems, and a message containing
the word "<null>" on others.


Fix:

/* 
 * Finish off a filled-in header block and write it out.
 * We also print the file name and/or full info if verbose is on.
 */
void
finish_header(header)
    register union record *header;
{
    register int    i, sum;
    register char   *p;

    bcopy(CHKBLANKS, header->header.chksum, sizeof(header->header.chksum));

    sum = 0;
    p = header->charptr;
    for (i = sizeof(*header); --i >= 0; ) {
        /*
         * We can't use unsigned char here because of old compilers,
         * e.g. V7.
         */
        sum += 0xFF & *p++;
    }

    /*
     * Fill in the checksum field.  It's formatted differently
     * from the other fields:  it has [6] digits, a null, then a
     * space -- rather than digits, a space, then a null.
     * We use to_oct then write the null in over to_oct's space.
     * The final space is already there, from checksumming, and
     * to_oct doesn't modify it.
     *
     * This is a fast way to do:
     * (void) sprintf(header->header.chksum, "%6o", sum);
     */
    to_oct((long) sum,  8,  header->header.chksum);
    header->header.chksum[6] = '\0';    /* Zap the space */

    userec(header);

    if (f_verbose) {
        extern union record *head;      /* Points to current tape header */
        extern int head_standard;       /* Tape header is in ANSI format */

        /* These globals are parameters to print_header, sigh */
        head = header;
        /* hstat is already set up */
        head_standard = f_standard;

************************************************************************
*       /* Greg Brown - need to set up current file name too.          *
*        * If we dont, we end up with a NULL pointer in                *
*        * quote_copy_string - Bad.                                    *
*        */                                                            *
*                                                                      *
*       current_file_name = head->header.arch_name;                    *
************************************************************************

		print_header();
	}

	return;
}

Thanks for reporting this problem, Larry.

Greg Brown - x2161

-----------------------------------------------------------------

Forwarded by:

Larry Armijo
COLSA@WSMR-SIMTEL20.ARMY.MIL

Newsgroups: gnu.utils.bug