aboutsummaryrefslogtreecommitdiff
path: root/util-linux/fdisk.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-07-25 12:08:26 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-07-25 12:08:26 +0200
commit163e637ffb47425d9f5027755b7cb4877d77b0cb (patch)
tree6be5abf74361fc15470099ebfe48d192ba49fdd8 /util-linux/fdisk.c
parent81de30de05beebabfa72f2a01ec4f33e9a1923e3 (diff)
downloadbusybox-w32-163e637ffb47425d9f5027755b7cb4877d77b0cb.tar.gz
busybox-w32-163e637ffb47425d9f5027755b7cb4877d77b0cb.tar.bz2
busybox-w32-163e637ffb47425d9f5027755b7cb4877d77b0cb.zip
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>
Diffstat (limited to 'util-linux/fdisk.c')
-rw-r--r--util-linux/fdisk.c9
1 files changed, 6 insertions, 3 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;
169 * do not support more than 2^32 sectors 169 * do not support more than 2^32 sectors
170 */ 170 */
171typedef uint32_t sector_t; 171typedef uint32_t sector_t;
172#if UINT_MAX == 4294967295 172#if UINT_MAX == 0xffffffff
173# define SECT_FMT "" 173# define SECT_FMT ""
174#elif ULONG_MAX == 4294967295 174#elif ULONG_MAX == 0xffffffff
175# define SECT_FMT "l" 175# define SECT_FMT "l"
176#else 176#else
177# error Cant detect sizeof(uint32_t) 177# 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 *
1616 int minus = (*line_ptr == '-'); 1616 int minus = (*line_ptr == '-');
1617 int absolute = 0; 1617 int absolute = 0;
1618 1618
1619 value = atoi(line_ptr + 1); 1619 if (sizeof(value) <= sizeof(long))
1620 value = strtoul(line_ptr + 1, NULL, 10);
1621 else
1622 value = strtoull(line_ptr + 1, NULL, 10);
1620 1623
1621 /* (1) if 2nd char is digit, use_default = 0. 1624 /* (1) if 2nd char is digit, use_default = 0.
1622 * (2) move line_ptr to first non-digit. */ 1625 * (2) move line_ptr to first non-digit. */