union block *header;
name = safer_name_suffix (name, 0);
- if (name[0] == '.' && name[1] == 0) /*FIXME!!!*/
- return NULL;
assign_string (&st->file_name, name);
header = write_header_name (st);
return ((link1->dev ^ link2->dev) | (link1->ino ^ link2->ino)) == 0;
}
+/* Copy at most LEN bytes from SRC to DST. Terminate with NUL unless
+ SRC is LEN characters long */
+static void
+tar_copy_str (char *dst, const char *src, size_t len)
+{
+ dst[len-1] = 0;
+ strncpy (dst, src, len);
+}
+
/* Table of all non-directories that we've written so far. Any time
we see another, we check the table and avoid dumping the data
again if we've done it once already. */
block_ordinal = current_block_ordinal ();
current_stat_info.stat.st_size = 0; /* force 0 size on dir */
- /* FIXME: If people could really read standard archives, this
- should be:
-
- header
- = start_header (standard_option ? p : namebuf, ¤t_stat_info);
-
- but since they'd interpret DIRTYPE blocks as regular
- files, we'd better put the / on the name. */
-
header = start_header (namebuf, ¤t_stat_info);
if (!header)
return;
block_ordinal = current_block_ordinal ();
assign_string (¤t_stat_info.link_name, link_name);
- if (NAME_FIELD_SIZE <= strlen (link_name))
+ if (NAME_FIELD_SIZE < strlen (link_name))
write_long_link (¤t_stat_info);
current_stat_info.stat.st_size = 0;
header = start_header (p, ¤t_stat_info);
if (!header)
return;
- strncpy (header->header.linkname, link_name, NAME_FIELD_SIZE);
-
- /* Force null termination. */
- header->header.linkname[NAME_FIELD_SIZE - 1] = 0;
+ tar_copy_str (header->header.linkname, link_name,
+ NAME_FIELD_SIZE);
header->header.typeflag = LNKTYPE;
finish_header (header, block_ordinal);
sizeleft = current_stat_info.stat.st_size;
- /* Don't bother opening empty, world readable files. Also do not open
- files when archive is meant for /dev/null. */
+ /* Don't bother opening empty, world readable files. Also do not
+ open files when archive is meant for /dev/null. */
if (dev_null_output
|| (sizeleft == 0
isextended = header->oldgnu_header.isextended;
else
isextended = 0;
- if (isextended)
- abort();
+
save_typeflag = header->header.typeflag;
finish_header (header, block_ordinal);
if (isextended)
}
buffer[size] = '\0';
assign_string (¤t_stat_info.link_name, buffer);
- if (size >= NAME_FIELD_SIZE)
+ if (size > NAME_FIELD_SIZE)
write_long_link (¤t_stat_info);
block_ordinal = current_block_ordinal ();
header = start_header (p, ¤t_stat_info);
if (!header)
return;
- strncpy (header->header.linkname, buffer, NAME_FIELD_SIZE);
- header->header.linkname[NAME_FIELD_SIZE - 1] = '\0';
+ tar_copy_str (header->header.linkname, buffer, NAME_FIELD_SIZE);
header->header.typeflag = SYMTYPE;
finish_header (header, block_ordinal);
/* nothing more to do to it */