[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] invalid assumption in src/incremen.c
From: |
Eric Blake |
Subject: |
Re: [Bug-tar] invalid assumption in src/incremen.c |
Date: |
Wed, 17 Aug 2005 06:33:38 -0600 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Sergey Poznyakoff on 8/16/2005 2:46 AM:
>>src/incremen.c makes the invalid assumption that ino_t is no bigger than
>>long. But since the 1.5.x release of cygwin (keyed by
>>__CYGWIN_USE_BIG_TYPES__ in headers), long is 4 bytes, while ino_t is 8
>>bytes. This bug appears to be the cause of the breakage of test 20 of
>>tar-1.15.1 on cygwin, since --listed output was being truncated.
>
>
> Thanks for reporting. Please try attached patch.
The patch indeed fixes the listed02.at test on cygwin.
> +static uintmax_t
> +getnum (char *p, char **endp)
> +{
> + uintmax_t n = 0;
> +
> + while (*p && isspace (*p))
> + p++;
> +
> + for (;ISDIGIT (*p); p++)
> + {
> + uintmax_t n10 = n * 10;
> + uintmax_t c = n10 + *p - '0';
> + if (n10 / 10 != n || c < n10)
> + {
> + errno = ERANGE;
> + n = -1;
> + break;
> + }
> + n = c;
> + }
> + *endp = p;
> + return n;
> +}
Wouldn't POSIX strtoumax (already a gnulib module) be better than rolling
your own?
> +
> static FILE *listed_incremental_stream;
>
> void
> @@ -344,8 +368,9 @@ read_directory_file (void)
> char *ebuf;
> int n;
> long lineno = 1;
> - unsigned long u = (errno = 0, strtoul (buf, &ebuf, 10));
> + uintmax_t u = (errno = 0, strtoul (buf, &ebuf, 10));
strtoul may be to short for uintmax_t, did you mean to use getnum or
strtoumax here?
- --
Life is short - so eat dessert first!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDAy6i84KuGfSFAYARAhQxAJ9ITWVP8rMXBgiAyNoALuNvwTDE5wCfWj6R
1uV0ff4WgwRLqCt1c73kGxw=
=onNb
-----END PGP SIGNATURE-----