qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking
@ 2018-03-11 20:12 Nia Alarie
  2018-03-12  9:01 ` Greg Kurz
  2018-03-12 12:12 ` Eric Blake
  0 siblings, 2 replies; 10+ messages in thread
From: Nia Alarie @ 2018-03-11 20:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: groug, stefanha, jim, joel, Nia Alarie

Signed-off-by: Nia Alarie <nia.alarie@gmail.com>
---
 hw/9pfs/9p.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 48fa48e720..64f3bb976c 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -15,6 +15,7 @@
 #include <glib/gprintf.h>
 #include "hw/virtio/virtio.h"
 #include "qapi/error.h"
+#include "qemu/cutils.h"
 #include "qemu/error-report.h"
 #include "qemu/iov.h"
 #include "qemu/sockets.h"
@@ -2213,8 +2214,15 @@ static void coroutine_fn v9fs_create(void *opaque)
         }
         v9fs_path_copy(&fidp->path, &path);
     } else if (perm & P9_STAT_MODE_LINK) {
-        int32_t ofid = atoi(extension.data);
-        V9fsFidState *ofidp = get_fid(pdu, ofid);
+        long ofid;
+        V9fsFidState *ofidp;
+
+        if (qemu_strtol(extension.data, NULL, 10, &ofid) ||
+            ofid > INT32_MAX || ofid < INT32_MIN) {
+            err = -EINVAL;
+            goto out;
+        }
+        ofidp = get_fid(pdu, (int32_t)ofid);
         if (ofidp == NULL) {
             err = -EINVAL;
             goto out;
-- 
2.16.2

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-03-13 16:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-11 20:12 [Qemu-devel] [PATCH] 9p: Convert use of atoi to qemu_strtol to allow error checking Nia Alarie
2018-03-12  9:01 ` Greg Kurz
2018-03-12 13:16   ` Greg Kurz
2018-03-12 12:12 ` Eric Blake
2018-03-12 13:02   ` Greg Kurz
2018-03-12 13:08     ` Daniel P. Berrangé
2018-03-12 13:21       ` Greg Kurz
2018-03-13 15:25         ` nee
2018-03-13 15:52           ` Stefan Hajnoczi
2018-03-13 16:28             ` Greg Kurz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).