summaryrefslogtreecommitdiff
path: root/lib9p/9p.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/9p.c')
-rw-r--r--lib9p/9p.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/lib9p/9p.c b/lib9p/9p.c
index 74a786c..78d23a0 100644
--- a/lib9p/9p.c
+++ b/lib9p/9p.c
@@ -128,10 +128,6 @@ ssize_t _lib9p_validate(uint8_t xxx_low_typ_bit,
.ctx = ctx,
.net_size = uint32le_decode(net_bytes),
.net_bytes = net_bytes,
-
- /* output */
- .net_offset = 0,
- .host_extra = 0,
};
if (subctx.net_size < 5)
return lib9p_error(ctx, LINUX_EBADMSG, "message is impossibly short");
@@ -145,18 +141,7 @@ ssize_t _lib9p_validate(uint8_t xxx_low_typ_bit,
lib9p_msgtype_str(ctx->version, typ), lib9p_version_str(ctx->version));
/* Now use the message-type-specific tentry to process the whole thing. */
- if (tentry.validate(&subctx))
- return -1;
- assert(subctx.net_offset <= subctx.net_size);
- if (subctx.net_offset < subctx.net_size)
- return lib9p_errorf(ctx, LINUX_EBADMSG, "message has %"PRIu32" extra bytes",
- subctx.net_size - subctx.net_offset);
-
- /* Return. */
- ssize_t ret;
- if (__builtin_add_overflow(tentry.basesize, subctx.host_extra, &ret))
- return lib9p_error(ctx, LINUX_EMSGSIZE, "unmarshalled payload overflows SSIZE_MAX");
- return ret;
+ return tentry.validate(&subctx);
}
ssize_t lib9p_Tmsg_validate(struct lib9p_ctx *ctx, uint8_t *net_bytes) {
@@ -251,18 +236,12 @@ bool lib9p_stat_validate(struct lib9p_ctx *ctx, uint32_t net_size, uint8_t *net_
.ctx = ctx,
.net_size = net_size,
.net_bytes = net_bytes,
-
- /* output */
- .net_offset = 0,
- .host_extra = 0,
};
- if (_lib9p_stat_validate(&subctx))
+ ssize_t host_size = _lib9p_stat_validate(&subctx, ret_net_size);
+ if (host_size < 0)
return true;
- if (ret_net_size)
- *ret_net_size = subctx.net_offset;
if (ret_host_size)
- if (__builtin_add_overflow(sizeof(struct lib9p_stat), subctx.host_extra, ret_host_size))
- return lib9p_error(ctx, LINUX_EMSGSIZE, "unmarshalled stat object overflows SSIZE_MAX");
+ *ret_host_size = host_size;
return false;
}