Skip to contentSkip to conversation

control: enable octal and hexadecimal parse

PATCH Applied [email protected] 2 participants 2 messages Jan 14, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 control: enable octal and hexadecimal parse

From: "Lu, Han" <[email protected]>

Use zero-base for strtol(), so get_integer() and get_integer64() can parse decimal, octal and hexadecimal data from input string.

src/control/ctlparse.c +2 -2
index 978977d..8d6c385 100644
@@ -59,7 +59,7 @@ static long get_integer(const char **ptr, long min, long max)
 		goto out;
 
 	s = p;
-	val = strtol(s, &p, 10);
+	val = strtol(s, &p, 0);
 	if (*p == '.') {
 		p++;
 		strtol(p, &p, 10);
@@ -87,7 +87,7 @@ static long long get_integer64(const char **ptr, long long min, long long max)
 		goto out;
 
 	s = p;
-	val = strtol(s, &p, 10);
+	val = strtol(s, &p, 0);
 	if (*p == '.') {
 		p++;
 		strtol(p, &p, 10);
Signature · 1 line
1.9.1
Applied
#1 lore raw

At Wed, 14 Jan 2015 09:08:30 +0800,

Quoted 7 lines · [email protected] wrote:

From: "Lu, Han" <[email protected]>

Use zero-base for strtol(), so get_integer() and get_integer64() can parse decimal, octal and hexadecimal data from input string.

Applied, thanks.

Takashi

Quoted 26 lines
src/control/ctlparse.c +2 -2
index 978977d..8d6c385 100644
@@ -59,7 +59,7 @@ static long get_integer(const char **ptr, long min, long max)
 		goto out;
 
 	s = p;
-	val = strtol(s, &p, 10);
+	val = strtol(s, &p, 0);
 	if (*p == '.') {
 		p++;
 		strtol(p, &p, 10);
@@ -87,7 +87,7 @@ static long long get_integer64(const char **ptr, long long min, long long max)
 		goto out;
 
 	s = p;
-	val = strtol(s, &p, 10);
+	val = strtol(s, &p, 0);
 	if (*p == '.') {
 		p++;
 		strtol(p, &p, 10);
Signature · 1 line
1.9.1