mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-09-06 00:06:54 +00:00
maint: port to Fedora 33
Fedora 33 uses GCC 10.2.1, which is a bit pickier. * configure.ac: Do not use -Wsystem-headers, as this runs afoul of netdb.h on Fedora 33. * gnulib.modules: Add ‘attribute’. * lib/wordsplit.c (wsnode_new): Return the newly allocated pointer instead of a boolean, to pacify GCC 10.2.1 which otherwise complains about use of possibly-null pointers. All uses changed. * src/buffer.c (try_new_volume): Don’t assume find_next_block succeeds. (_write_volume_label): Pacify GCC 10.2.1 with an ‘assume’, since LABEL must be nonnull here. * src/common.h (FALLTHROUGH): Remove; now in attribute.h. Include attribute.h, for ATTRIBUTE_NONNULL. * src/misc.c (assign_string_or_null): New function, taking over the old role of assign_string. (assign_string): Assume VALUE is non-null. (assign_null): New function, taking over the old role of assign_string when its VALUE was nonnull. All callers of assign_string changed to use these functions. (assign_string_n): Clear *STRING if VALUE is null, to fix a potential double-free.
This commit is contained in:
+5
-3
@@ -28,6 +28,7 @@
|
||||
#include <fnmatch.h>
|
||||
#include <human.h>
|
||||
#include <quotearg.h>
|
||||
#include <verify.h>
|
||||
|
||||
#include "common.h"
|
||||
#include <rmt.h>
|
||||
@@ -1325,8 +1326,8 @@ new_volume (enum access_mode mode)
|
||||
if (verify_option)
|
||||
verify_volume ();
|
||||
|
||||
assign_string (&volume_label, NULL);
|
||||
assign_string (&continued_file_name, NULL);
|
||||
assign_null (&volume_label);
|
||||
assign_null (&continued_file_name);
|
||||
continued_file_size = continued_file_offset = 0;
|
||||
current_block = record_start;
|
||||
|
||||
@@ -1505,7 +1506,7 @@ try_new_volume (void)
|
||||
ASSIGN_STRING_N (&volume_label, current_header->header.name);
|
||||
set_next_block_after (header);
|
||||
header = find_next_block ();
|
||||
if (header->header.typeflag != GNUTYPE_MULTIVOL)
|
||||
if (! (header && header->header.typeflag == GNUTYPE_MULTIVOL))
|
||||
break;
|
||||
FALLTHROUGH;
|
||||
case GNUTYPE_MULTIVOL:
|
||||
@@ -1688,6 +1689,7 @@ _write_volume_label (const char *str)
|
||||
{
|
||||
union block *label = find_next_block ();
|
||||
|
||||
assume (label);
|
||||
memset (label, 0, BLOCKSIZE);
|
||||
|
||||
strcpy (label->header.name, str);
|
||||
|
||||
+5
-7
@@ -43,18 +43,13 @@
|
||||
# define GLOBAL extern
|
||||
#endif
|
||||
|
||||
#if 7 <= __GNUC__
|
||||
# define FALLTHROUGH __attribute__ ((__fallthrough__))
|
||||
#else
|
||||
# define FALLTHROUGH ((void) 0)
|
||||
#endif
|
||||
|
||||
#define TAREXIT_SUCCESS PAXEXIT_SUCCESS
|
||||
#define TAREXIT_DIFFERS PAXEXIT_DIFFERS
|
||||
#define TAREXIT_FAILURE PAXEXIT_FAILURE
|
||||
|
||||
|
||||
#include "arith.h"
|
||||
#include <attribute.h>
|
||||
#include <backupfile.h>
|
||||
#include <exclude.h>
|
||||
#include <full-write.h>
|
||||
@@ -633,7 +628,10 @@ void skip_member (void);
|
||||
#define max(a, b) ((a) < (b) ? (b) : (a))
|
||||
|
||||
char const *quote_n_colon (int n, char const *arg);
|
||||
void assign_string (char **dest, const char *src);
|
||||
void assign_string_or_null (char **dest, const char *src)
|
||||
ATTRIBUTE_NONNULL ((1));
|
||||
void assign_string (char **dest, const char *src) ATTRIBUTE_NONNULL ((1, 2));
|
||||
void assign_null (char **dest) ATTRIBUTE_NONNULL ((1));
|
||||
void assign_string_n (char **string, const char *value, size_t n);
|
||||
#define ASSIGN_STRING_N(s,v) assign_string_n (s, v, sizeof (v))
|
||||
int unquote_string (char *str);
|
||||
|
||||
+11
-11
@@ -520,7 +520,7 @@ delay_set_stat (char const *file_name, struct tar_stat_info const *st,
|
||||
data->change_dir = chdir_current;
|
||||
data->cntx_name = NULL;
|
||||
if (st)
|
||||
assign_string (&data->cntx_name, st->cntx_name);
|
||||
assign_string_or_null (&data->cntx_name, st->cntx_name);
|
||||
if (st && st->acls_a_ptr)
|
||||
{
|
||||
data->acls_a_ptr = xmemdup (st->acls_a_ptr, st->acls_a_len + 1);
|
||||
@@ -1329,7 +1329,7 @@ extract_file (char *file_name, int typeflag)
|
||||
first. If it doesn't exist, there is no matching entry in the list.
|
||||
Otherwise, look for the entry in list which has the matching dev
|
||||
and ino numbers.
|
||||
|
||||
|
||||
This approach avoids scanning the singly-linked list in obvious cases
|
||||
and does not rely on comparing file names, which may differ for
|
||||
various reasons (e.g. relative vs. absolute file names).
|
||||
@@ -1342,14 +1342,14 @@ find_delayed_link_source (char const *name)
|
||||
|
||||
if (!delayed_link_head)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (fstatat (chdir_fd, name, &st, AT_SYMLINK_NOFOLLOW))
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
stat_error (name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
for (dl = delayed_link_head; dl; dl = dl->next)
|
||||
{
|
||||
if (dl->dev == st.st_dev && dl->ino == st.st_ino)
|
||||
@@ -1357,7 +1357,7 @@ find_delayed_link_source (char const *name)
|
||||
}
|
||||
return dl;
|
||||
}
|
||||
|
||||
|
||||
/* Create a placeholder file with name FILE_NAME, which will be
|
||||
replaced after other extraction is done by a symbolic link if
|
||||
IS_SYMLINK is true, and by a hard link otherwise. Set
|
||||
@@ -1385,7 +1385,7 @@ create_placeholder_file (char *file_name, bool is_symlink, bool *interdir_made,
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
switch (maybe_recoverable (file_name, false, interdir_made))
|
||||
{
|
||||
case RECOVER_OK:
|
||||
@@ -1442,7 +1442,7 @@ create_placeholder_file (char *file_name, bool is_symlink, bool *interdir_made,
|
||||
p->sources->next = 0;
|
||||
strcpy (p->sources->string, file_name);
|
||||
p->cntx_name = NULL;
|
||||
assign_string (&p->cntx_name, current_stat_info.cntx_name);
|
||||
assign_string_or_null (&p->cntx_name, current_stat_info.cntx_name);
|
||||
p->acls_a_ptr = NULL;
|
||||
p->acls_a_len = 0;
|
||||
p->acls_d_ptr = NULL;
|
||||
@@ -1467,7 +1467,7 @@ extract_link (char *file_name, int typeflag)
|
||||
char const *link_name;
|
||||
int rc;
|
||||
struct delayed_link *dl;
|
||||
|
||||
|
||||
link_name = current_stat_info.link_name;
|
||||
|
||||
if (! absolute_names_option && contains_dot_dot (link_name))
|
||||
@@ -1475,7 +1475,7 @@ extract_link (char *file_name, int typeflag)
|
||||
dl = find_delayed_link_source (link_name);
|
||||
if (dl)
|
||||
return create_placeholder_file (file_name, false, &interdir_made, dl);
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
struct stat st1, st2;
|
||||
@@ -1697,7 +1697,7 @@ prepare_to_extract (char const *file_name, int typeflag, tar_extractor_t *fun)
|
||||
|
||||
case GNUTYPE_VOLHDR:
|
||||
return false;
|
||||
|
||||
|
||||
case GNUTYPE_MULTIVOL:
|
||||
ERROR ((0, 0,
|
||||
_("%s: Cannot extract -- file is continued from another volume"),
|
||||
@@ -1753,7 +1753,7 @@ prepare_to_extract (char const *file_name, int typeflag, tar_extractor_t *fun)
|
||||
}
|
||||
}
|
||||
*fun = extractor;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+26
-7
@@ -42,11 +42,28 @@ quote_n_colon (int n, char const *arg)
|
||||
|
||||
/* Assign STRING to a copy of VALUE if not zero, or to zero. If
|
||||
STRING was nonzero, it is freed first. */
|
||||
void
|
||||
assign_string_or_null (char **string, const char *value)
|
||||
{
|
||||
if (value)
|
||||
assign_string (string, value);
|
||||
else
|
||||
assign_null (string);
|
||||
}
|
||||
|
||||
void
|
||||
assign_string (char **string, const char *value)
|
||||
{
|
||||
free (*string);
|
||||
*string = value ? xstrdup (value) : 0;
|
||||
*string = xstrdup (value);
|
||||
}
|
||||
|
||||
void
|
||||
assign_null (char **string)
|
||||
{
|
||||
char *old = *string;
|
||||
*string = NULL;
|
||||
free (old);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -61,6 +78,8 @@ assign_string_n (char **string, const char *value, size_t n)
|
||||
p[l] = 0;
|
||||
*string = p;
|
||||
}
|
||||
else
|
||||
*string = NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -715,7 +734,7 @@ maybe_backup_file (const char *file_name, bool this_is_the_archive)
|
||||
possible, real problems are unlikely. Doing any better would require a
|
||||
convention, GNU-wide, for all programs doing backups. */
|
||||
|
||||
assign_string (&after_backup_name, 0);
|
||||
assign_null (&after_backup_name);
|
||||
|
||||
/* Check if we really need to backup the file. */
|
||||
|
||||
@@ -758,7 +777,7 @@ maybe_backup_file (const char *file_name, bool this_is_the_archive)
|
||||
ERROR ((0, e, _("%s: Cannot rename to %s"),
|
||||
quotearg_colon (before_backup_name),
|
||||
quote_n (1, after_backup_name)));
|
||||
assign_string (&after_backup_name, 0);
|
||||
assign_null (&after_backup_name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -782,7 +801,7 @@ undo_last_backup (void)
|
||||
fprintf (stdlis, _("Renaming %s back to %s\n"),
|
||||
quote_n (0, after_backup_name),
|
||||
quote_n (1, before_backup_name));
|
||||
assign_string (&after_backup_name, 0);
|
||||
assign_null (&after_backup_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1041,11 +1060,11 @@ tar_getcdpath (int idx)
|
||||
{
|
||||
int i;
|
||||
int save_cwdi = chdir_current;
|
||||
|
||||
|
||||
for (i = idx; i >= 0; i--)
|
||||
if (wd[i].abspath)
|
||||
break;
|
||||
|
||||
|
||||
while (++i <= idx)
|
||||
{
|
||||
chdir_do (i);
|
||||
@@ -1069,7 +1088,7 @@ tar_getcdpath (int idx)
|
||||
|
||||
chdir_do (save_cwdi);
|
||||
}
|
||||
|
||||
|
||||
return wd[idx].abspath;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user