summaryrefslogtreecommitdiff
path: root/src/create.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-01-22 17:52:42 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2010-01-22 17:52:42 +0200
commitcd91cd3c629e3c489e5ab4650f443cdcfeec670a (patch)
tree42705856b420107fd80b53dc39a136b92d1bcc33 /src/create.c
parentcac45fffc58cc10056c528582ee4b78b8ee175e0 (diff)
downloadtar-cd91cd3c629e3c489e5ab4650f443cdcfeec670a.tar.gz
Fix prefix length calculation in ustar mode.
* src/create.c (split_long_name): Fix prefix length calculation. (write_ustar_long_name): Improve ustar mode compatibility with the Sun version.
Diffstat (limited to 'src/create.c')
-rw-r--r--src/create.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/create.c b/src/create.c
index 3add5a06..8c66d9bc 100644
--- a/src/create.c
+++ b/src/create.c
@@ -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"),