Skip to contentSkip to conversation

eal: clear errno before calling strtoull() to parse base_virtaddr

PATCH In review Aaron Campbell 2 participants 3 messages Jun 19, 2014 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal: clear errno before calling strtoull() to parse base_virtaddr

Must reset errno to zero before calling strtoull(), else on success it could be any arbitrary value from past errors.

---
 lib/librte_eal/linuxapp/eal/eal.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_eal/linuxapp/eal/eal.c +1 -0
index 6994303..d204387 100644
@@ -562,6 +562,7 @@ eal_parse_base_virtaddr(const char *arg)
 	char *end;
 	uint64_t addr;
 
+	errno = 0;
 	addr = strtoull(arg, &end, 16);
 
 	/* check for errors */
Signature · 1 line
1.8.3.2

A message that is not in the archive (sent off-list or not yet received): 1403192557-10905-1-git-send-email-aaron-rd7evPjynkNeoWH0uzbU5w@public.gmane.org

#2 lore raw

Hi Aaron,

It seems that Pablo De Lara has beat you to it by a few minutes :-) Are there any other places this could potentially happen?

Quoted 22 lines

Must reset errno to zero before calling strtoull(), else on success it could be any arbitrary value from past errors.

---
 lib/librte_eal/linuxapp/eal/eal.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_eal/linuxapp/eal/eal.c +1 -1
index 6994303..d204387 100644
@@ -562,6 +562,7 @@ eal_parse_base_virtaddr(const char *arg)
 	char *end;
 	uint64_t addr;
 
+	errno = 0;
 	addr = strtoull(arg, &end, 16);
 
 	/* check for errors */
--

1.8.3.2

A message that is not in the archive (sent off-list or not yet received): C6ECDF3AB251BE4894318F4E451236976CC9D71C-kPTMFJFq+rF9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org

#4 lore raw

Yes, that was extremely bizarre. I didn’t check the whole project, but at least eal_parse_socket_mem() in the same file was already correct. Pablo you can add me to Acked-by, obviously. :-)

-Aaron

Quoted 27 lines · Anatoly

Hi Aaron,

It seems that Pablo De Lara has beat you to it by a few minutes :-) Are there any other places this could potentially happen?

Quoted 22 lines

Must reset errno to zero before calling strtoull(), else on success it could be any arbitrary value from past errors.

---
lib/librte_eal/linuxapp/eal/eal.c | 1 +

1 file changed, 1 insertion(+)
lib/librte_eal/linuxapp/eal/eal.c +1 -1
index 6994303..d204387 100644
@@ -562,6 +562,7 @@ eal_parse_base_virtaddr(const char *arg)
 	char *end;
 	uint64_t addr;
 
+	errno = 0;
 	addr = strtoull(arg, &end, 16);
 
 	/* check for errors */
--

1.8.3.2