Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-07-25 13:08:26 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2018-07-30 19:02:27 +0300
commit096ccd6a691f3c5e5cdae1a67fd45b9340b14f27 (patch)
treed13e09d43ee04b9652271ea085b4d20897ff3dcd
parentd674b2e2aeb10f0755a197084f962287740fbc50 (diff)
fdisk: use strtoul[l] instead of atoi, closes 11176
Couldn't create partitions bigger than 1TB (when using 512 bytes sectors, on 32 bits architectures). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/fdisk.c9
-rw-r--r--util-linux/fdisk_sun.c2
2 files changed, 7 insertions, 4 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index cdcba0a03..e47bc7324 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -169,9 +169,9 @@ typedef unsigned long long ullong;
* do not support more than 2^32 sectors
*/
typedef uint32_t sector_t;
-#if UINT_MAX == 4294967295
+#if UINT_MAX == 0xffffffff
# define SECT_FMT ""
-#elif ULONG_MAX == 4294967295
+#elif ULONG_MAX == 0xffffffff
# define SECT_FMT "l"
#else
# error Cant detect sizeof(uint32_t)
@@ -1616,7 +1616,10 @@ read_int(sector_t low, sector_t dflt, sector_t high, sector_t base, const char *
int minus = (*line_ptr == '-');
int absolute = 0;
- value = atoi(line_ptr + 1);
+ if (sizeof(value) <= sizeof(long))
+ value = strtoul(line_ptr + 1, NULL, 10);
+ else
+ value = strtoull(line_ptr + 1, NULL, 10);
/* (1) if 2nd char is digit, use_default = 0.
* (2) move line_ptr to first non-digit. */
diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index e32740dea..f62a53ac6 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -606,7 +606,7 @@ sun_change_sysid(int i, int sys)
"there may destroy your partition table and bootblock.\n"
"Type YES if you're very sure you would like that partition\n"
"tagged with 82 (Linux swap): ");
- if (strcmp (line_ptr, "YES\n"))
+ if (strcmp(line_ptr, "YES\n"))
return;
}
switch (sys) {