The test program src/test-nextquota.c relies on atoi() to convert a
string to an *unsigned* int. If the string represents an integer
which is greater than INT_MAX, it is undefined how atoi(3) works,
and it turns out that:
uint id = atoi("
2147483649");
results in id ==
2147483649 on x86_64, and id ==
2147483647 on a
32-bit x86 platform.
So use strtoul(3) instead, which is portable and technically correct
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
int verbose = 0;
uint id = 0, idflag = 0;
char *device = NULL;
+ char *tmp;
struct nextdqblk dqb;
struct fs_disk_quota xqb;
typeflag++;
break;
case 'i':
- id = atoi(optarg);
+ id = (uint) strtoul(optarg, &tmp, 0);
+ if (*tmp) {
+ fprintf(stderr, "Bad id: %s\n", optarg);
+ exit(1);
+ }
idflag++;
break;
case 'd':