Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Jul 2011 21:08:16 +0000 (UTC)
From:      Ryan Stone <rstone@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r224150 - head/sbin/fdisk
Message-ID:  <201107172108.p6HL8Gkd090278@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rstone
Date: Sun Jul 17 21:08:16 2011
New Revision: 224150
URL: http://svn.freebsd.org/changeset/base/224150

Log:
  The MBR uses a 32-bit unsigned integer to store the size of a slice, but
  fdisk(1) internally uses a signed int.  Should a user attempt to specify
  a slice containing more than 2^31 - 1 sectors, an error will be reported
  on systems with sizeof(long) == 4 and the slice size will be silently
  truncated on systems with sizeof(long) > 4.
  
  Instead use an unsigned long to store the slice size in fdisk(1).  This
  allows the user to specify a slice size up to the maximum permitted by
  the MBR on-disk format and does not have any problems with silent
  truncation should the use specify an slice size larger than 2^32 on systems
  with sizeof(long) > 4.
  
  Submitted by:	Mark Johnston (markjdb AT gmail DOT com)
  MFC after:	2 weeks

Modified:
  head/sbin/fdisk/fdisk.c

Modified: head/sbin/fdisk/fdisk.c
==============================================================================
--- head/sbin/fdisk/fdisk.c	Sun Jul 17 20:49:38 2011	(r224149)
+++ head/sbin/fdisk/fdisk.c	Sun Jul 17 21:08:16 2011	(r224150)
@@ -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 *comma
 	    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?201107172108.p6HL8Gkd090278>