[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] v9fs_walk: As per 9p2000 RFC, MAXWELEM >= nwnames >
From: |
Harsh Prateek Bora |
Subject: |
[Qemu-devel] [PATCH] v9fs_walk: As per 9p2000 RFC, MAXWELEM >= nwnames >= 0. |
Date: |
Tue, 22 Mar 2011 00:01:55 +0530 |
The nwnames field in TWALK message is assumed to be >=0 and <= MAXWELEM
which is defined as macro P9_MAXWELEM (16) in virtio-9p.h as per 9p2000 RFC.
Appropriate changes are required in V9fsWalkState and v9fs_walk.
Signed-off-by: Harsh Prateek Bora <address@hidden>
---
hw/9pfs/virtio-9p.c | 5 ++++-
hw/9pfs/virtio-9p.h | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 9b44bd0..b782a19 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -1805,7 +1805,7 @@ static void v9fs_walk(V9fsState *s, V9fsPDU *pdu)
vs->offset += pdu_unmarshal(vs->pdu, vs->offset, "ddw", &fid,
&newfid, &vs->nwnames);
- if (vs->nwnames) {
+ if (vs->nwnames <= P9_MAXWELEM) {
vs->wnames = qemu_mallocz(sizeof(vs->wnames[0]) * vs->nwnames);
vs->qids = qemu_mallocz(sizeof(vs->qids[0]) * vs->nwnames);
@@ -1814,6 +1814,9 @@ static void v9fs_walk(V9fsState *s, V9fsPDU *pdu)
vs->offset += pdu_unmarshal(vs->pdu, vs->offset, "s",
&vs->wnames[i]);
}
+ } else {
+ err = -EINVAL;
+ goto out;
}
vs->fidp = lookup_fid(s, fid);
diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h
index e7d2326..119b12c 100644
--- a/hw/9pfs/virtio-9p.h
+++ b/hw/9pfs/virtio-9p.h
@@ -307,7 +307,7 @@ typedef struct V9fsStatStateDotl {
typedef struct V9fsWalkState {
V9fsPDU *pdu;
size_t offset;
- int16_t nwnames;
+ uint16_t nwnames;
int name_idx;
V9fsQID *qids;
V9fsFidState *fidp;
--
1.7.1.1
- [Qemu-devel] [PATCH] v9fs_walk: As per 9p2000 RFC, MAXWELEM >= nwnames >= 0.,
Harsh Prateek Bora <=