X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fcreate.c;h=209e428ef820fac8f5d51dec4fe2c7b40f84896d;hb=6e196273a4c986a0ca9b894c8654c5b5e0777978;hp=3add5a0657e4c5357fdc9972def0a2d62ebfc4e4;hpb=cac45fffc58cc10056c528582ee4b78b8ee175e0;p=chaz%2Ftar diff --git a/src/create.c b/src/create.c index 3add5a0..209e428 100644 --- a/src/create.c +++ b/src/create.c @@ -1,7 +1,7 @@ /* Create a tar archive. Copyright (C) 1985, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, - 2003, 2004, 2005, 2006, 2007, 2009 Free Software Foundation, Inc. + 2003, 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. Written by John Gilmore, on 1985-08-25. @@ -602,8 +602,10 @@ split_long_name (const char *name, size_t length) { size_t i; - if (length > PREFIX_FIELD_SIZE) + if (length > PREFIX_FIELD_SIZE + 1) length = PREFIX_FIELD_SIZE + 1; + else if (ISSLASH (name[length - 1])) + length--; for (i = length - 1; i > 0; i--) if (ISSLASH (name[i])) break; @@ -614,9 +616,9 @@ static union block * write_ustar_long_name (const char *name) { size_t length = strlen (name); - size_t i; + size_t i, nlen; union block *header; - + if (length > PREFIX_FIELD_SIZE + NAME_FIELD_SIZE + 1) { ERROR ((0, 0, _("%s: file name is too long (max %d); not dumped"), @@ -626,7 +628,7 @@ write_ustar_long_name (const char *name) } i = split_long_name (name, length); - if (i == 0 || length - i - 1 > NAME_FIELD_SIZE) + if (i == 0 || (nlen = length - i - 1) > NAME_FIELD_SIZE || nlen == 0) { ERROR ((0, 0, _("%s: file name is too long (cannot be split); not dumped"), @@ -994,11 +996,9 @@ finish_header (struct tar_stat_info *st, && header->header.typeflag != XHDTYPE && header->header.typeflag != XGLTYPE) { - /* These globals are parameters to print_header, sigh. */ - - current_header = header; + /* FIXME: This global is used in print_header, sigh. */ current_format = archive_format; - print_header (st, block_ordinal); + print_header (st, header, block_ordinal); } header = write_extended (false, st, header);