Skip to contentSkip to conversation

9pfs: make illegal path name detection more robust

PATCH In review Li Qiang 2 participants 2 messages Sep 27, 2016

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 9pfs: make illegal path name detection more robust

From: Li Qiang <[email protected]>

The parameter of name_is_illegal can be NULL, adding detection of this to avoid NULL pointer dereference issue.

---
 hw/9pfs/9p.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/9p.c +1 -1
index dd3145c..d960a2e 100644
@@ -1277,7 +1277,7 @@ static int v9fs_walk_marshal(V9fsPDU *pdu, uint16_t nwnames, V9fsQID *qids)
 
 static bool name_is_illegal(const char *name)
 {
-    return !*name || strchr(name, '/') != NULL;
+    return !name || !*name || strchr(name, '/') != NULL;
 }
 
 static bool not_same_qid(const V9fsQID *qid1, const V9fsQID *qid2)
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 5 lines · On Mon, 26 Sep 2016 21:40:17 -0700 Li Qiang <[email protected]> wrote:

From: Li Qiang <[email protected]>

The parameter of name_is_illegal can be NULL, adding detection of this to avoid NULL pointer dereference issue.

Same as with the other patch: the root cause is in v9fs_iov_vunmarshal().

Quoted 18 lines
---
 hw/9pfs/9p.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/9pfs/9p.c +1 -1
index dd3145c..d960a2e 100644
@@ -1277,7 +1277,7 @@ static int v9fs_walk_marshal(V9fsPDU *pdu, uint16_t nwnames, V9fsQID *qids)
 
 static bool name_is_illegal(const char *name)
 {
-    return !*name || strchr(name, '/') != NULL;
+    return !name || !*name || strchr(name, '/') != NULL;
 }
 
 static bool not_same_qid(const V9fsQID *qid1, const V9fsQID *qid2)