1
1

vfs/tar.c (tar_read_header): Properly handle non \0 terminated tar entries

with name of length NAMSIZ.
Этот коммит содержится в:
Leonard den Ottolander 2005-07-06 14:15:54 +00:00
родитель 674dac483d
Коммит 133196d197
2 изменённых файлов: 16 добавлений и 7 удалений

Просмотреть файл

@ -1,3 +1,8 @@
2005-07-06 Pavel Tsekov <ptsekov@gmx.net>
* tar.c (tar_read_header): Properly handle non \0 terminated tar
entries with name of length NAMSIZ.
2005-07-05 Roland Illig <roland.illig@gmx.de>
* vfs.h, vfs-impl.h, vfs.c, local.h, local.c, sfs.c: Removed

Просмотреть файл

@ -401,10 +401,15 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
/*
* linkflag on BSDI tar (pax) always '\000'
*/
if (header->header.linkflag == '\000'
&& (i = strlen (header->header.arch_name))
&& header->header.arch_name[i - 1] == '/')
header->header.linkflag = LF_DIR;
if (header->header.linkflag == '\000') {
if (header->header.arch_name[NAMSIZ - 1] != '\0')
i = NAMSIZ;
else
i = strlen (header->header.arch_name);
if (i && header->header.arch_name[i - 1] == '/')
header->header.linkflag = LF_DIR;
}
/*
* Good record. Decode file size and return.
@ -422,7 +427,6 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
if (header->header.linkflag == LF_DUMPDIR)
return STATUS_SUCCESS;
header->header.arch_name[NAMSIZ - 1] = '\0';
if (header->header.linkflag == LF_LONGNAME
|| header->header.linkflag == LF_LONGLINK) {
char **longp;
@ -476,14 +480,14 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive,
current_link_name =
(next_long_link ? next_long_link :
g_strdup (header->header.arch_linkname));
g_strndup (header->header.arch_linkname, NAMSIZ));
len = strlen (current_link_name);
if (len > 1 && current_link_name[len - 1] == '/')
current_link_name[len - 1] = 0;
current_file_name =
(next_long_name ? next_long_name :
g_strdup (header->header.arch_name));
g_strndup (header->header.arch_name, NAMSIZ));
canonicalize_pathname (current_file_name);
len = strlen (current_file_name);