Date: Tue, 24 May 2011 11:46:02 -0400 From: Mark Johnston <markjdb@gmail.com> To: freebsd-fs@freebsd.org Subject: fdisk(1) uses a signed int for slice sizes Message-ID: <20110524154602.GA57782@oddish.mark-home>
next in thread | raw e-mail | index | archive | help
Hello all,
fdisk(1) uses a signed int to store slice sizes when reading in a config
file. On platforms with sizeof(int) == 4, this prevents users from
specifying a size of more than 2^{31}-1 sectors even though the
corresponding MBR field is a 32-bit unsigned number.
I have a little patch which fixes this; I was going to ask rstone@ to
commit it, but I'd like to know if there are any objections/comments first.
Thanks,
-Mark
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index 8314906..eb81e3b 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -108,9 +108,9 @@ typedef struct cmd {
char cmd;
int n_args;
struct arg {
- char argtype;
- int arg_val;
- char *arg_str;
+ char argtype;
+ unsigned long arg_val;
+ char * arg_str;
} args[MAX_ARGS];
} CMD;
@@ -990,7 +990,7 @@ parse_config_line(char *line, CMD *command)
if (isalpha(*cp))
command->args[command->n_args].argtype = *cp++;
end = NULL;
- command->args[command->n_args].arg_val = strtol(cp, &end, 0);
+ command->args[command->n_args].arg_val = strtoul(cp, &end, 0);
if (cp == end || (!isspace(*end) && *end != '\0')) {
char ch;
end = cp;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110524154602.GA57782>
