strncpy (dst, src, len);
}
+/* Same as tar_copy_str, but always terminate with NUL if using
+ is OLDGNU format */
+static void
+tar_name_copy_str (char *dst, const char *src, size_t len)
+{
+ tar_copy_str (dst, src, len);
+ if (archive_format == OLDGNU_FORMAT)
+ dst[len-1] = 0;
+}
+
/* Write a "private" header */
union block *
start_private_header (const char *name, size_t size)
memset (header->buffer, 0, sizeof (union block));
- tar_copy_str (header->header.name, name, NAME_FIELD_SIZE);
+ tar_name_copy_str (header->header.name, name, NAME_FIELD_SIZE);
OFF_TO_CHARS (size, header->header.size);
time (&t);
{
union block *header = find_next_block ();
memset (header->buffer, 0, sizeof (union block));
- tar_copy_str (header->header.name, st->file_name, NAME_FIELD_SIZE);
+ tar_name_copy_str (header->header.name, st->file_name, NAME_FIELD_SIZE);
return header;
}
xheader_store ("path", st, NULL);
return write_short_name (st);
}
- else if (NAME_FIELD_SIZE < strlen (st->file_name))
+ else if ((archive_format == OLDGNU_FORMAT
+ && OLDGNU_NAME_FIELD_SIZE < strlen (st->file_name))
+ || NAME_FIELD_SIZE < strlen (st->file_name))
return write_long_name (st);
else
return write_short_name (st);
block_ordinal = current_block_ordinal ();
assign_string (&st->link_name, link_name);
- if (NAME_FIELD_SIZE < strlen (link_name))
+ if ((archive_format == OLDGNU_FORMAT
+ && OLDGNU_NAME_FIELD_SIZE < strlen (link_name))
+ || NAME_FIELD_SIZE < strlen (link_name))
write_long_link (st);
st->stat.st_size = 0;
}
buffer[size] = '\0';
assign_string (&st->link_name, buffer);
- if (size > NAME_FIELD_SIZE)
+ if ((archive_format == OLDGNU_FORMAT && size > OLDGNU_NAME_FIELD_SIZE)
+ || size > NAME_FIELD_SIZE)
write_long_link (st);
block_ordinal = current_block_ordinal ();