(read_directory_file): Use strtoumax to read snapshot file contents.
This commit is contained in:
@@ -344,12 +344,13 @@ read_directory_file (void)
|
|||||||
char *ebuf;
|
char *ebuf;
|
||||||
int n;
|
int n;
|
||||||
long lineno = 1;
|
long lineno = 1;
|
||||||
unsigned long u = (errno = 0, strtoul (buf, &ebuf, 10));
|
uintmax_t u = (errno = 0, strtoumax (buf, &ebuf, 10));
|
||||||
time_t t = u;
|
time_t t = u;
|
||||||
|
|
||||||
if (buf == ebuf || (u == 0 && errno == EINVAL))
|
if (buf == ebuf || (u == 0 && errno == EINVAL))
|
||||||
ERROR ((0, 0, "%s:1: %s", quotearg_colon (listed_incremental_option),
|
ERROR ((0, 0, "%s:1: %s", quotearg_colon (listed_incremental_option),
|
||||||
_("Invalid time stamp")));
|
_("Invalid time stamp")));
|
||||||
else if (t != u || (u == -1 && errno == ERANGE))
|
else if (t != u)
|
||||||
ERROR ((0, 0, "%s:1: %s", quotearg_colon (listed_incremental_option),
|
ERROR ((0, 0, "%s:1: %s", quotearg_colon (listed_incremental_option),
|
||||||
_("Time stamp out of range")));
|
_("Time stamp out of range")));
|
||||||
else
|
else
|
||||||
@@ -373,24 +374,24 @@ read_directory_file (void)
|
|||||||
buf[n - 1] = '\0';
|
buf[n - 1] = '\0';
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
dev = u = strtoul (strp, &ebuf, 10);
|
dev = u = strtoumax (strp, &ebuf, 10);
|
||||||
if (strp == ebuf || (u == 0 && errno == EINVAL))
|
if (!isspace (*ebuf))
|
||||||
ERROR ((0, 0, "%s:%ld: %s",
|
ERROR ((0, 0, "%s:%ld: %s",
|
||||||
quotearg_colon (listed_incremental_option), lineno,
|
quotearg_colon (listed_incremental_option), lineno,
|
||||||
_("Invalid device number")));
|
_("Invalid device number")));
|
||||||
else if (dev != u || (u == -1 && errno == ERANGE))
|
else if (dev != u)
|
||||||
ERROR ((0, 0, "%s:%ld: %s",
|
ERROR ((0, 0, "%s:%ld: %s",
|
||||||
quotearg_colon (listed_incremental_option), lineno,
|
quotearg_colon (listed_incremental_option), lineno,
|
||||||
_("Device number out of range")));
|
_("Device number out of range")));
|
||||||
strp = ebuf;
|
strp = ebuf;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
ino = u = strtoul (strp, &ebuf, 10);
|
ino = u = strtoumax (strp, &ebuf, 10);
|
||||||
if (strp == ebuf || (u == 0 && errno == EINVAL))
|
if (!isspace (*ebuf))
|
||||||
ERROR ((0, 0, "%s:%ld: %s",
|
ERROR ((0, 0, "%s:%ld: %s",
|
||||||
quotearg_colon (listed_incremental_option), lineno,
|
quotearg_colon (listed_incremental_option), lineno,
|
||||||
_("Invalid inode number")));
|
_("Invalid inode number")));
|
||||||
else if (ino != u || (u == -1 && errno == ERANGE))
|
else if (ino != u)
|
||||||
ERROR ((0, 0, "%s:%ld: %s",
|
ERROR ((0, 0, "%s:%ld: %s",
|
||||||
quotearg_colon (listed_incremental_option), lineno,
|
quotearg_colon (listed_incremental_option), lineno,
|
||||||
_("Inode number out of range")));
|
_("Inode number out of range")));
|
||||||
@@ -419,11 +420,15 @@ write_directory_file_entry (void *entry, void *data)
|
|||||||
if (directory->found)
|
if (directory->found)
|
||||||
{
|
{
|
||||||
int e;
|
int e;
|
||||||
|
char buf[UINTMAX_STRSIZE_BOUND];
|
||||||
char *str = quote_copy_string (directory->name);
|
char *str = quote_copy_string (directory->name);
|
||||||
fprintf (fp, "+%lu %lu %s\n" + ! directory->nfs,
|
|
||||||
(unsigned long) directory->device_number,
|
if (directory->nfs)
|
||||||
(unsigned long) directory->inode_number,
|
fprintf (fp, "+");
|
||||||
str ? str : directory->name);
|
fprintf (fp, "%s ", umaxtostr (directory->device_number, buf));
|
||||||
|
fprintf (fp, "%s ", umaxtostr (directory->inode_number, buf));
|
||||||
|
fprintf (fp, "%s\n", str ? str : directory->name);
|
||||||
|
|
||||||
e = errno;
|
e = errno;
|
||||||
if (str)
|
if (str)
|
||||||
free (str);
|
free (str);
|
||||||
|
|||||||
Reference in New Issue
Block a user