Skip to contentSkip to conversation

net/slirp: Convert atoi to qemu_strtoi to allow error checking

PATCH Applied Nia Alarie 2 participants 2 messages Mar 16, 2018 Networking

lore
Share & tools
lore

Nia Alarie

author
#0 lore raw

PATCH 1/1 net/slirp: Convert atoi to qemu_strtoi to allow error checking

---
 net/slirp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/slirp.c +3 -1
index 8991816bbf..e938944bd4 100644
@@ -486,7 +486,9 @@ void hmp_hostfwd_remove(Monitor *mon, const QDict *qdict)
         goto fail_syntax;
     }
 
-    host_port = atoi(p);
+    if (qemu_strtoi(p, NULL, 10, &host_port)) {
+        goto fail_syntax;
+    }
 
     err = slirp_remove_hostfwd(s->slirp, is_udp, host_addr, host_port);
 
Signature · 1 line
2.16.2
#1 lore raw
Quoted 1 line · Nia Alarie, on ven. 16 mars 2018 14:39:21 +0000, wrote:

Applied to my tree, thanks!

Quoted 22 lines
---
 net/slirp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/slirp.c +3 -1
index 8991816bbf..e938944bd4 100644
@@ -486,7 +486,9 @@ void hmp_hostfwd_remove(Monitor *mon, const QDict *qdict)
         goto fail_syntax;
     }
 
-    host_port = atoi(p);
+    if (qemu_strtoi(p, NULL, 10, &host_port)) {
+        goto fail_syntax;
+    }
 
     err = slirp_remove_hostfwd(s->slirp, is_udp, host_addr, host_port);
 
Signature · 1 line
2.16.2
Signature · 3 lines
Samuel
"...[Linux's] capacity to talk via any medium except smoke signals."
(By Dr. Greg Wettstein, Roger Maris Cancer Center)