summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2006-03-08 08:06:46 +0000
committerLudovic Courtès <ludo@gnu.org>2006-03-08 08:06:46 +0000
commitb7887d7799ec81cf04ab649bc808a1703db212a4 (patch)
treecac9115f308ba7f490f98f0ec19ca9e75ff1f5bf
parent7bb75af0024e6e17eff763e932aae0e78379d091 (diff)
Applied patch from Ben Asselstine; passes `ustar-all-quickest.tar' now.
-rw-r--r--BUGS1
-rw-r--r--ChangeLog13
-rw-r--r--store-gzip.c2
-rw-r--r--tar.c18
-rw-r--r--tarfs.c15
-rw-r--r--zipstores.c2
6 files changed, 39 insertions, 12 deletions
diff --git a/BUGS b/BUGS
index b7e993658..1c946b366 100644
--- a/BUGS
+++ b/BUGS
@@ -4,7 +4,6 @@ Known tarfs bugs
1. General
-* Doesn't pass the "ustar-all-quickest.tar" test file with long links.
* io_map () not implemented (gcc uses it unfortunately).
* netfs.c (netfs_get_dirents): too much memory may be allocated (mmap'd).
diff --git a/ChangeLog b/ChangeLog
index d0d7f4dae..8bed1754e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2006-03-07 Ben Asselstine <benasselstine@gmail.com>
+
+ * store-gzip.c (read_next): remove static from nested
+ function declaration.
+ * tarfs.c (sync_archive): Likewise.
+ (read_archive): Likewise.
+ * zipstores.c (do_write): Likewise.
+ * tar.c (read_header): Correctly handle archive names and
+ archive link names when they are exactly NAMSIZ characters long.
+ * tarfs.c (add_header): Likewise.
+ * TODO: Removed `ustar-all-quickest.tar' which passes now.
+
+
2002-12-04
* tarlist.c (tar_put_item): Fixed a bug in placing "foo/bar".
diff --git a/store-gzip.c b/store-gzip.c
index 66e479059..8f4896743 100644
--- a/store-gzip.c
+++ b/store-gzip.c
@@ -178,7 +178,7 @@ gzip_read_header (struct store *store,
size_t amount, index = 0;
/* Load next block and continue */
- static inline
+ inline
error_t read_next ()
{
error_t err;
diff --git a/tar.c b/tar.c
index 0b38028fe..31bf61ea3 100644
--- a/tar.c
+++ b/tar.c
@@ -204,6 +204,13 @@ read_header (struct store *tar_file)
static char *next_lonname = NULL, *next_lonlink = NULL;
char *current_file_name, *current_link_name;
struct stat hstat; /* Stat struct corresponding */
+ char arch_name[NAMSIZ + 1];
+ char arch_linkname[NAMSIZ + 1];
+
+ memcpy (arch_name, header->header.arch_name, NAMSIZ);
+ arch_name [NAMSIZ] = '\0';
+ memcpy (arch_linkname, header->header.arch_linkname, NAMSIZ);
+ arch_linkname [NAMSIZ] = '\0';
recurse:
@@ -249,9 +256,10 @@ recurse:
/*
* linkflag on BSDI tar (pax) always '\000'
*/
+
if (header->header.linkflag == '\000' &&
- strlen (header->header.arch_name) &&
- header->header.arch_name[strlen (header->header.arch_name) - 1] == '/')
+ strlen (arch_name) &&
+ arch_name[strlen (arch_name) - 1] == '/')
header->header.linkflag = LF_DIR;
/*
@@ -262,7 +270,6 @@ recurse:
else
hstat.st_size = from_oct (1 + 12, header->header.size);
- header->header.arch_name[NAMSIZ - 1] = '\0';
if (header->header.linkflag == LF_LONGNAME
|| header->header.linkflag == LF_LONGLINK)
{
@@ -289,7 +296,7 @@ recurse:
current_file_name = (next_lonname
? next_lonname
- : strdup (header->header.arch_name));
+ : strdup (arch_name));
len = strlen (current_file_name);
if (current_file_name[len - 1] == '/')
{
@@ -297,9 +304,10 @@ recurse:
isdir = 1;
}
+
current_link_name = (next_lonlink
? next_lonlink
- : strdup (header->header.arch_linkname));
+ : strdup (arch_linkname));
len = strlen (current_link_name);
if (len && current_link_name[len - 1] == '/')
current_link_name[len - 1] = 0;
diff --git a/tarfs.c b/tarfs.c
index dc163d779..fbca8e8af 100644
--- a/tarfs.c
+++ b/tarfs.c
@@ -331,11 +331,15 @@ tarfs_add_header (tar_record_t *hdr, off_t offset)
static struct tar_item *last_item = NULL;
struct node *dir, *new = NULL;
char *name, *notfound, *retry;
+ char arch_name[NAMSIZ + 1];
assert (hdr != NULL);
dir = netfs_root_node;
- name = D (hdr->header.arch_name);
+
+ memcpy (arch_name, hdr->header.arch_name, NAMSIZ);
+ arch_name[NAMSIZ] = '\0';
+ name = strdup (arch_name);
assert (name);
debug (("name = %s", name));
@@ -357,6 +361,7 @@ tarfs_add_header (tar_record_t *hdr, off_t offset)
NEW_NODE_INFO (new);*/
free (name);
name = retry;
+ dir = new;
}
}
while (retry);
@@ -387,7 +392,9 @@ tarfs_add_header (tar_record_t *hdr, off_t offset)
debug (("Hard linking \"%s\"", name));
/* Get the target's node first. */
- tgname = strdup (hdr->header.arch_linkname);
+ tgname = malloc (NAMSIZ + 1);
+ memcpy (tgname, hdr->header.arch_linkname, NAMSIZ);
+ tgname [NAMSIZ] = '\0';
target = netfs_root_node;
fs_find_node_path (&target, &retry, &notfound, tgname);
@@ -483,7 +490,7 @@ tarfs_init (struct node **root, struct iouser *user)
mode_t mode = 0644;
/* Sync the archive. */
- static void
+ void
sync_archive ()
{
error_t tarfs_sync_fs (int wait);
@@ -498,7 +505,7 @@ tarfs_init (struct node **root, struct iouser *user)
}
/* Reads and parses a tar archive, possibly in a separate thread. */
- static void
+ void
read_archive ()
{
error_t err;
diff --git a/zipstores.c b/zipstores.c
index 5ae29f52f..e0f1d83ae 100644
--- a/zipstores.c
+++ b/zipstores.c
@@ -267,7 +267,7 @@ ZIP (stream_write_init) (struct ZIP (object) *zip)
/* Check whether we need to write a gzip header */
if (!zip->source->size)
{
- static error_t
+ error_t
do_write (char *buf, size_t amount)
{
size_t len;