summaryrefslogtreecommitdiffstats
path: root/src/vfs/tar
diff options
context:
space:
mode:
Diffstat (limited to 'src/vfs/tar')
-rw-r--r--src/vfs/tar/Makefile.in2
-rw-r--r--src/vfs/tar/tar-internal.c21
-rw-r--r--src/vfs/tar/tar-internal.h3
-rw-r--r--src/vfs/tar/tar-sparse.c16
-rw-r--r--src/vfs/tar/tar-xheader.c2
-rw-r--r--src/vfs/tar/tar.c22
6 files changed, 33 insertions, 33 deletions
diff --git a/src/vfs/tar/Makefile.in b/src/vfs/tar/Makefile.in
index c89786e..79cd3e1 100644
--- a/src/vfs/tar/Makefile.in
+++ b/src/vfs/tar/Makefile.in
@@ -134,7 +134,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-sfs.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-ftp.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-sftp.m4 \
- $(top_srcdir)/m4.include/vfs/mc-vfs-fish.m4 \
+ $(top_srcdir)/m4.include/vfs/mc-vfs-shell.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-undelfs.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-tarfs.m4 \
$(top_srcdir)/m4.include/vfs/mc-vfs-cpiofs.m4 \
diff --git a/src/vfs/tar/tar-internal.c b/src/vfs/tar/tar-internal.c
index f77b1b3..2c4a0ad 100644
--- a/src/vfs/tar/tar-internal.c
+++ b/src/vfs/tar/tar-internal.c
@@ -1,7 +1,7 @@
/*
Virtual File System: GNU Tar file system.
- Copyright (C) 2023
+ Copyright (C) 2023-2024
Free Software Foundation, Inc.
Written by:
@@ -32,7 +32,6 @@
#include <config.h>
-#include <ctype.h> /* isspace() */
#include <inttypes.h> /* uintmax_t */
#include <stdint.h> /* UINTMAX_MAX, etc */
@@ -184,6 +183,14 @@ tar_seek_archive (tar_super_t * archive, off_t size)
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
+gboolean
+is_octal_digit (char c)
+{
+ return '0' <= c && c <= '7';
+}
+
+/* --------------------------------------------------------------------------------------------- */
+
void
tar_base64_init (void)
{
@@ -262,13 +269,13 @@ tar_from_header (const char *where0, size_t digs, char const *type, intmax_t min
if (where == lim)
return (-1);
- if (!isspace ((unsigned char) *where))
+ if (!g_ascii_isspace (*where))
break;
where++;
}
- if (isodigit (*where))
+ if (is_octal_digit (*where))
{
char const *where1 = where;
gboolean overflow = FALSE;
@@ -276,7 +283,7 @@ tar_from_header (const char *where0, size_t digs, char const *type, intmax_t min
while (TRUE)
{
value += *where++ - '0';
- if (where == lim || !isodigit (*where))
+ if (where == lim || !is_octal_digit (*where))
break;
overflow |= value != (value << LG_8 >> LG_8);
value <<= LG_8;
@@ -301,7 +308,7 @@ tar_from_header (const char *where0, size_t digs, char const *type, intmax_t min
{
value += 7 - digit;
where++;
- if (where == lim || !isodigit (*where))
+ if (where == lim || !is_octal_digit (*where))
break;
digit = *where - '0';
overflow |= value != (value << LG_8 >> LG_8);
@@ -373,7 +380,7 @@ tar_from_header (const char *where0, size_t digs, char const *type, intmax_t min
value = -value;
}
- if (where != lim && *where != '\0' && !isspace ((unsigned char) *where))
+ if (where != lim && *where != '\0' && !g_ascii_isspace (*where))
return (-1);
if (value <= (negative ? minus_minval : maxval))
diff --git a/src/vfs/tar/tar-internal.h b/src/vfs/tar/tar-internal.h
index 7b3bb53..e0ce577 100644
--- a/src/vfs/tar/tar-internal.h
+++ b/src/vfs/tar/tar-internal.h
@@ -65,8 +65,6 @@
#define OFF_FROM_HEADER(where) off_from_header (where, sizeof (where))
-#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
-
/*** enums ***************************************************************************************/
/*** structures declarations (and typedefs of structures)*****************************************/
@@ -302,6 +300,7 @@ extern struct tar_stat_info current_stat_info;
/*** declarations of public functions ************************************************************/
/* tar-internal.c */
+gboolean is_octal_digit (char c);
void tar_base64_init (void);
void tar_assign_string (char **string, char *value);
void tar_assign_string_dup (char **string, const char *value);
diff --git a/src/vfs/tar/tar-sparse.c b/src/vfs/tar/tar-sparse.c
index 0bc169b..9795d15 100644
--- a/src/vfs/tar/tar-sparse.c
+++ b/src/vfs/tar/tar-sparse.c
@@ -1,7 +1,7 @@
/*
Virtual File System: GNU Tar file system.
- Copyright (C) 2003-2023
+ Copyright (C) 2003-2024
Free Software Foundation, Inc.
Written by:
@@ -547,8 +547,8 @@ oldgnu_get_sparse_info (tar_super_t * archive, struct tar_sparse_file *file)
{
size_t i;
union block *h = current_header;
- int ext_p;
- enum oldgnu_add_status rc;
+ gboolean ext_p;
+ enum oldgnu_add_status rc = add_fail;
if (file->stat_info->sparse_map != NULL)
g_array_set_size (file->stat_info->sparse_map, 0);
@@ -560,8 +560,8 @@ oldgnu_get_sparse_info (tar_super_t * archive, struct tar_sparse_file *file)
break;
}
- for (ext_p = h->oldgnu_header.isextended ? 1 : 0; rc == add_ok && ext_p != 0;
- ext_p = h->sparse_header.isextended ? 1 : 0)
+ for (ext_p = h->oldgnu_header.isextended != 0; rc == add_ok && ext_p;
+ ext_p = h->sparse_header.isextended != 0)
{
h = tar_find_next_block (archive);
if (h == NULL)
@@ -612,7 +612,7 @@ star_get_sparse_info (tar_super_t * archive, struct tar_sparse_file *file)
{
size_t i;
union block *h = current_header;
- int ext_p = 1;
+ gboolean ext_p = TRUE;
enum oldgnu_add_status rc = add_ok;
if (file->stat_info->sparse_map != NULL)
@@ -628,10 +628,10 @@ star_get_sparse_info (tar_super_t * archive, struct tar_sparse_file *file)
break;
}
- ext_p = h->star_in_header.isextended ? 1 : 0;
+ ext_p = h->star_in_header.isextended != 0;
}
- for (; rc == add_ok && ext_p != 0; ext_p = h->star_ext_header.isextended ? 1 : 0)
+ for (; rc == add_ok && ext_p; ext_p = h->star_ext_header.isextended != 0)
{
h = tar_find_next_block (archive);
if (h == NULL)
diff --git a/src/vfs/tar/tar-xheader.c b/src/vfs/tar/tar-xheader.c
index 5062ed1..c4c79de 100644
--- a/src/vfs/tar/tar-xheader.c
+++ b/src/vfs/tar/tar-xheader.c
@@ -1,7 +1,7 @@
/*
Virtual File System: GNU Tar file system.
- Copyright (C) 1995-2023
+ Copyright (C) 1995-2024
Free Software Foundation, Inc.
Written by:
diff --git a/src/vfs/tar/tar.c b/src/vfs/tar/tar.c
index 2d32111..4ce6494 100644
--- a/src/vfs/tar/tar.c
+++ b/src/vfs/tar/tar.c
@@ -1,7 +1,7 @@
/*
Virtual File System: GNU Tar file system.
- Copyright (C) 1995-2023
+ Copyright (C) 1995-2024
Free Software Foundation, Inc.
Written by:
@@ -87,6 +87,8 @@ struct tar_stat_info current_stat_info;
#define XGLTYPE 'g' /* Global extended header */
/* Values used in typeflag field. */
+#define REGTYPE '0' /* regular file */
+#define AREGTYPE '\0' /* regular file */
#define LNKTYPE '1' /* link */
#define SYMTYPE '2' /* symbolic link */
#define CHRTYPE '3' /* character special */
@@ -123,7 +125,6 @@ struct tar_stat_info current_stat_info;
#define MODE_FROM_HEADER(where,hbits) mode_from_header (where, sizeof (where), hbits)
#define TIME_FROM_HEADER(where) time_from_header (where, sizeof (where))
#define UID_FROM_HEADER(where) uid_from_header (where, sizeof (where))
-#define UINTMAX_FROM_HEADER(where) uintmax_from_header (where, sizeof (where))
/*** file scope type declarations ****************************************************************/
@@ -247,14 +248,6 @@ uid_from_header (const char *p, size_t s)
/* --------------------------------------------------------------------------------------------- */
-static inline uintmax_t
-uintmax_from_header (const char *p, size_t s)
-{
- return tar_from_header (p, s, "uintmax_t", 0, UINTMAX_MAX, FALSE);
-}
-
-/* --------------------------------------------------------------------------------------------- */
-
static void
tar_calc_sparse_offsets (struct vfs_s_inode *inode)
{
@@ -304,7 +297,7 @@ tar_skip_member (tar_super_t * archive, struct vfs_s_inode *inode)
}
else if (save_typeflag != DIRTYPE)
{
- if (inode != NULL)
+ if (inode != NULL && (save_typeflag == REGTYPE || save_typeflag == AREGTYPE))
inode->data_offset = BLOCKSIZE * tar_current_block_ordinal (archive);
return tar_skip_file (archive, current_stat_info.stat.st_size);
@@ -390,8 +383,10 @@ tar_decode_header (union block *header, tar_super_t * arch)
{
if (strcmp (header->header.magic, TMAGIC) == 0)
{
- if (header->star_header.prefix[130] == 0 && isodigit (header->star_header.atime[0])
- && header->star_header.atime[11] == ' ' && isodigit (header->star_header.ctime[0])
+ if (header->star_header.prefix[130] == 0
+ && is_octal_digit (header->star_header.atime[0])
+ && header->star_header.atime[11] == ' '
+ && is_octal_digit (header->star_header.ctime[0])
&& header->star_header.ctime[11] == ' ')
arch->type = TAR_STAR;
else if (current_stat_info.xhdr.buffer != NULL)
@@ -588,7 +583,6 @@ tar_insert_entry (struct vfs_class *me, struct vfs_s_super *archive, union block
(*inode)->st.st_mtime = current_stat_info.mtime.tv_sec;
(*inode)->st.st_atime = current_stat_info.atime.tv_sec;
(*inode)->st.st_ctime = current_stat_info.ctime.tv_sec;
- (*inode)->data_offset = BLOCKSIZE * tar_current_block_ordinal (TAR_SUPER (archive));
if (link_name != NULL && *link_name != '\0')
(*inode)->linkname = g_strdup (link_name);