9pfs: simplify v9fs_walk()
PATCH 1/1 9pfs: simplify v9fs_walk()
There is only one comparison between nwnames and P9_MAXWELEM required.
Signed-off-by Christian Schoenebeck <[email protected]>
--- hw/9pfs/9p.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
hw/9pfs/9p.c +5 -4
@@ -1739,7 +1739,11 @@ static void coroutine_fn v9fs_walk(void *opaque)trace_v9fs_walk (pdu->tag, pdu->id, fid, newfid, nwnames); -if (nwnames && nwnames <=P9_MAXWELEM ) { +if (nwnames >P9_MAXWELEM ) { + err = -EINVAL ; + goto out_nofid; + } +if (nwnames) { wnames =g_new0 (V9fsString, nwnames); qids =g_new0 (V9fsQID, nwnames);for (i =0 ; i < nwnames; i++) {
@@ -1753,9 +1757,6 @@ static void coroutine_fn v9fs_walk(void *opaque) } offset += err; } - }else if (nwnames >P9_MAXWELEM ) { - err = -EINVAL ; - goto out_nofid; } fidp =get_fid (pdu, fid);if (fidp ==NULL ) {
Signature · 1 line
2.20.1
Quoted 4 lines · On Sun, 16 May 2021 17:55:34 +0200 Christian Schoenebeck…
There is only one comparison between nwnames and
P9_MAXWELEMrequired.Signed-off-by Christian Schoenebeck <[email protected]>---
Nice catch. It's been there for a decade :)
Reviewed-by Greg Kurz <[email protected]>
Quoted 30 lines
hw/9pfs/9p.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)hw/9pfs/9p.c +5
-4@@ -1739,7 +1739,11 @@ static void coroutine_fn v9fs_walk(void *opaque)trace_v9fs_walk (pdu->tag, pdu->id, fid, newfid, nwnames); -if (nwnames && nwnames <=P9_MAXWELEM ) { +if (nwnames >P9_MAXWELEM ) { + err = -EINVAL ; + goto out_nofid; + } +if (nwnames) { wnames =g_new0 (V9fsString, nwnames); qids =g_new0 (V9fsQID, nwnames);for (i =0 ; i < nwnames; i++) {@@ -1753,9 +1757,6 @@ static void coroutine_fn v9fs_walk(void *opaque) } offset += err; } - }else if (nwnames >P9_MAXWELEM ) { - err = -EINVAL ; - goto out_nofid; } fidp =get_fid (pdu, fid);if (fidp ==NULL ) {
Quoted 11 lines · On Montag, 17. Mai 2021 13:35:09 CEST Greg Kurz wrote:
On Sun, 16 May 2021 17:55:34 +0200
Quoted 4 lines · Christian Schoenebeck
There is only one comparison between nwnames and
P9_MAXWELEMrequired.Signed-off-by Christian Schoenebeck <[email protected]>---
Nice catch. It's been there for a decade :)
Reviewed-by Greg Kurz <[email protected]>
Now that was a quick response! Queued, thanks!
https://github.com/cschoenebeck/qemu/commits/9p.next
Quoted 37 lines
Quoted 37 lines
hw/9pfs/9p.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)hw/9pfs/9p.c +5
-1@@ -1739,7 +1739,11 @@ static void coroutine_fn v9fs_walk(void *opaque)trace_v9fs_walk (pdu->tag, pdu->id, fid, newfid, nwnames); -if (nwnames && nwnames <=P9_MAXWELEM ) { +if (nwnames >P9_MAXWELEM ) { + err = -EINVAL ; + goto out_nofid; + } +if (nwnames) { wnames =g_new0 (V9fsString, nwnames); qids =g_new0 (V9fsQID, nwnames);for (i = 0; i < nwnames; i++) {hw/9pfs/9p.c +0
-3@@ -1753,9 +1757,6 @@ static void coroutine_fn v9fs_walk(void *opaque) } offset += err; } - }else if (nwnames >P9_MAXWELEM ) { - err = -EINVAL ; - goto out_nofid;} fidp = get_fid(pdu, fid); if (fidp == NULL) {