"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "strtonum.c" between
mtools-4.0.35.tar.bz2 and mtools-4.0.36.tar.bz2

About: Mtools is a collection of utilities to access MS-DOS disks from Unix without mounting them.

strtonum.c  (mtools-4.0.35.tar.bz2):strtonum.c  (mtools-4.0.36.tar.bz2)
skipping to change at line 88 skipping to change at line 88
return strtou16(str, 0, 0); return strtou16(str, 0, 0);
} }
uint32_t strtou32(const char *nptr, char **endptr, int base) { uint32_t strtou32(const char *nptr, char **endptr, int base) {
return (uint32_t) strtoul_with_range(nptr, endptr, base, UINT32_MAX); return (uint32_t) strtoul_with_range(nptr, endptr, base, UINT32_MAX);
} }
uint32_t atou32(const char *str) { uint32_t atou32(const char *str) {
return strtou32(str, 0, 0); return strtou32(str, 0, 0);
} }
static void checkOverflow(uint32_t tot_sectors, int bits) {
if(tot_sectors > UINT32_MAX >> bits) {
fprintf(stderr, "Too many sectors\n");
exit(1);
}
}
uint32_t parseSize(char *sizeStr) {
char *eptr;
uint32_t tot_sectors = strtou32(sizeStr, &eptr, 10);
if(eptr == sizeStr) {
fprintf(stderr, "Bad size %s\n", sizeStr);
exit(1);
}
switch(toupper(*eptr)) {
case 'T':
checkOverflow(tot_sectors, 10);
tot_sectors *= 1024;
/* FALL THROUGH */
case 'G':
checkOverflow(tot_sectors, 10);
tot_sectors *= 1024;
/* FALL THROUGH */
case 'M':
checkOverflow(tot_sectors, 10);
tot_sectors *= 1024;
/* FALL THROUGH */
case 'K':
checkOverflow(tot_sectors, 1);
tot_sectors *= 2;
eptr++;
break;
case '\0':
/* By default, assume sectors */
break;
}
if(*eptr) {
fprintf(stderr, "Bad suffix %s\n", eptr);
exit(1);
}
return tot_sectors;
}
 End of changes. 1 change blocks. 
0 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)