|
@@ -469,20 +469,11 @@ p9_parse_header(struct p9_fcall *pdu, int32_t *size, int8_t *type, int16_t *tag,
|
|
int err;
|
|
int err;
|
|
|
|
|
|
pdu->offset = 0;
|
|
pdu->offset = 0;
|
|
- if (pdu->size == 0)
|
|
|
|
- pdu->size = 7;
|
|
|
|
|
|
|
|
err = p9pdu_readf(pdu, 0, "dbw", &r_size, &r_type, &r_tag);
|
|
err = p9pdu_readf(pdu, 0, "dbw", &r_size, &r_type, &r_tag);
|
|
if (err)
|
|
if (err)
|
|
goto rewind_and_exit;
|
|
goto rewind_and_exit;
|
|
|
|
|
|
- pdu->size = r_size;
|
|
|
|
- pdu->id = r_type;
|
|
|
|
- pdu->tag = r_tag;
|
|
|
|
-
|
|
|
|
- p9_debug(P9_DEBUG_9P, "<<< size=%d type: %d tag: %d\n",
|
|
|
|
- pdu->size, pdu->id, pdu->tag);
|
|
|
|
-
|
|
|
|
if (type)
|
|
if (type)
|
|
*type = r_type;
|
|
*type = r_type;
|
|
if (tag)
|
|
if (tag)
|
|
@@ -490,6 +481,16 @@ p9_parse_header(struct p9_fcall *pdu, int32_t *size, int8_t *type, int16_t *tag,
|
|
if (size)
|
|
if (size)
|
|
*size = r_size;
|
|
*size = r_size;
|
|
|
|
|
|
|
|
+ if (pdu->size != r_size || r_size < 7) {
|
|
|
|
+ err = -EINVAL;
|
|
|
|
+ goto rewind_and_exit;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ pdu->id = r_type;
|
|
|
|
+ pdu->tag = r_tag;
|
|
|
|
+
|
|
|
|
+ p9_debug(P9_DEBUG_9P, "<<< size=%d type: %d tag: %d\n",
|
|
|
|
+ pdu->size, pdu->id, pdu->tag);
|
|
|
|
|
|
rewind_and_exit:
|
|
rewind_and_exit:
|
|
if (rewind)
|
|
if (rewind)
|
|
@@ -516,6 +517,12 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
|
|
int ecode;
|
|
int ecode;
|
|
|
|
|
|
err = p9_parse_header(req->rc, NULL, &type, NULL, 0);
|
|
err = p9_parse_header(req->rc, NULL, &type, NULL, 0);
|
|
|
|
+ if (req->rc->size >= c->msize) {
|
|
|
|
+ p9_debug(P9_DEBUG_ERROR,
|
|
|
|
+ "requested packet size too big: %d\n",
|
|
|
|
+ req->rc->size);
|
|
|
|
+ return -EIO;
|
|
|
|
+ }
|
|
/*
|
|
/*
|
|
* dump the response from server
|
|
* dump the response from server
|
|
* This should be after check errors which poplulate pdu_fcall.
|
|
* This should be after check errors which poplulate pdu_fcall.
|