[ipxe-devel] Patch: Correct marking of end in strtoul()

Earl Chew earl_chew at yahoo.com
Thu Nov 5 01:53:01 UTC 2015


This patch corrects a deficiency in strtoul() which causes endptr to
indicate the wrong part of the string.


commit d300d708ec0ec54fd8f0405cf4addc17ff5df5fc
Author: Earl Chew <earl_chew at yahoo.com>
Date:   Sun Nov 1 08:01:34 2015 -0800

     [string] Correct marking of end in strtoul()

     Signed-off-by: Earl Chew <earl_chew at yahoo.com>

diff --git a/src/string.c b/src/string.c
index 6ddcc9c..022fdaa 100644
--- a/src/string.c
+++ b/src/string.c
@@ -273,7 +273,7 @@ unsigned long strtoul ( const char *nptr, char 
**endptr, int base ) {

  	/* Parse digits */
  	while ( 1 ) {
-		digit = *(nptr++);
+		digit = *nptr;
  		if ( digit >= 'a' ) {
  			digit = ( digit - 'a' + 10 );
  		} else if ( digit >= 'A' ) {
@@ -283,6 +283,7 @@ unsigned long strtoul ( const char *nptr, char 
**endptr, int base ) {
  		}
  		if ( digit >= ( unsigned int ) base )
  			break;
+		++nptr;
  		val = ( ( val * base ) + digit );
  	}




More information about the ipxe-devel mailing list