When an unsigned long is wider than an afs_uint32, comparing the
afs_uint32 vid to ULONG_MAX is always going to be false (which the
compiler can warn us about). Fix this by storing to an unsigned long,
and converting to a volume id after ensuring that the result is not
too large.
Change-Id: Ifbd724dabd988bc4b1ba6ee8f3dc7fa1a0afb226
Reviewed-on: http://gerrit.openafs.org/4244
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk>
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
}
if ((ti = as->parms[1].items)) { /* -volumeid */
char *end;
+ unsigned long vid_l;
seenvol = 1;
- vid = strtoul(ti->data, &end, 10);
- if (vid == ULONG_MAX || *end != '\0') {
+ vid_l = strtoul(ti->data, &end, 10);
+ if (vid_l >= MAX_AFS_UINT32 || vid_l == ULONG_MAX || *end != '\0') {
printf("Invalid volume id specified; salvage aborted\n");
exit(-1);
}
+ vid = (VolumeId)vid_l;
}
if (ShowLog) {
}
if ((ti = as->parms[1].items)) { /* -volumeid */
char *end;
+ unsigned long vid_l;
if (!seenpart) {
printf
("You must also specify '-partition' option with the '-volumeid' option\n");
exit(-1);
}
seenvol = 1;
- vid = strtoul(ti->data, &end, 10);
- if (vid == ULONG_MAX || *end != '\0') {
+ vid_l = strtoul(ti->data, &end, 10);
+ if (vid_l >= MAX_AFS_UINT32 || vid_l == ULONG_MAX || *end != '\0') {
Log("salvage: invalid volume id specified; salvage aborted\n");
Exit(1);
}
+ vid = (VolumeId)vid_l;
}
if (as->parms[2].items) /* -debug */
debug = 1;