summaryrefslogtreecommitdiff
path: root/lib9p/9p.generated.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/9p.generated.c')
-rw-r--r--lib9p/9p.generated.c70
1 files changed, 41 insertions, 29 deletions
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c
index b2243e2..b24c6e8 100644
--- a/lib9p/9p.generated.c
+++ b/lib9p/9p.generated.c
@@ -383,9 +383,10 @@ static ALWAYS_INLINE bool validate_qid(struct _validate_ctx *ctx) {
}
static ALWAYS_INLINE bool validate_stat(struct _validate_ctx *ctx) {
- uint32_t size_offset = ctx->net_offset;
- return validate_2(ctx)
- || validate_2(ctx)
+ uint16_t stat_size;
+ uint32_t _kern_type_offset;
+ return (validate_2(ctx) || ({ stat_size = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; }))
+ || ({ _kern_type_offset = ctx->net_offset; validate_2(ctx); })
|| validate_4(ctx)
|| validate_qid(ctx)
|| validate_dm(ctx)
@@ -400,9 +401,8 @@ static ALWAYS_INLINE bool validate_stat(struct _validate_ctx *ctx) {
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) )
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) )
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && validate_4(ctx) )
- || ((uint32_t)decode_u16le(&ctx->net_bytes[size_offset]) != ctx->net_offset - (size_offset+2)
- ? lib9p_error(ctx->ctx, LINUX_EBADMSG, "stat size does not match stat contents")
- : false);
+ || ({ uint32_t correct = ctx->net_offset - _kern_type_offset; (((uint32_t)stat_size) != correct) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "stat_size value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)stat_size, correct); });
}
static ALWAYS_INLINE bool validate_o(struct _validate_ctx *ctx) {
@@ -463,22 +463,18 @@ static FLATTEN bool validate_Rflush(struct _validate_ctx *UNUSED(ctx)) {
}
static FLATTEN bool validate_Twalk(struct _validate_ctx *ctx) {
+ uint16_t nwname;
return validate_4(ctx)
|| validate_4(ctx)
- || validate_2(ctx)
- || (decode_u16le(&ctx->net_bytes[ctx->net_offset-2]) > (uint16_t)(16)
- ? lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "list size is too large (%"PRIu16" > %"PRIu16")",
- decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), (uint16_t)(16))
- : false)
+ || (validate_2(ctx) || ({ nwname = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; }))
+ || (nwname > UINT16_C(16) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nwname value too large (%"PRIu16" > %"PRIu16")", nwname, UINT16_C(16)))
|| _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s));
}
static FLATTEN bool validate_Rwalk(struct _validate_ctx *ctx) {
- return validate_2(ctx)
- || (decode_u16le(&ctx->net_bytes[ctx->net_offset-2]) > (uint16_t)(16)
- ? lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "list size is too large (%"PRIu16" > %"PRIu16")",
- decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), (uint16_t)(16))
- : false)
+ uint16_t nwqid;
+ return (validate_2(ctx) || ({ nwqid = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; }))
+ || (nwqid > UINT16_C(16) && lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nwqid value too large (%"PRIu16" > %"PRIu16")", nwqid, UINT16_C(16)))
|| _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_qid, sizeof(struct lib9p_qid));
}
@@ -545,12 +541,22 @@ static FLATTEN bool validate_Tstat(struct _validate_ctx *ctx) {
}
static FLATTEN bool validate_Rstat(struct _validate_ctx *ctx) {
- return validate_stat(ctx);
+ uint16_t nstat;
+ uint32_t _stat_offset;
+ return (validate_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; }))
+ || ({ _stat_offset = ctx->net_offset; validate_stat(ctx); })
+ || ({ uint32_t correct = ctx->net_offset - _stat_offset; (((uint32_t)nstat) != correct) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nstat value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)nstat, correct); });
}
static FLATTEN bool validate_Twstat(struct _validate_ctx *ctx) {
+ uint16_t nstat;
+ uint32_t _stat_offset;
return validate_4(ctx)
- || validate_stat(ctx);
+ || (validate_2(ctx) || ({ nstat = decode_u16le(&ctx->net_bytes[ctx->net_offset-2]); false; }))
+ || ({ _stat_offset = ctx->net_offset; validate_stat(ctx); })
+ || ({ uint32_t correct = ctx->net_offset - _stat_offset; (((uint32_t)nstat) != correct) &&
+ lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "nstat value wrong (actual:%"PRIu32" != correct:%"PRIu32")", (uint32_t)nstat, correct); });
}
static FLATTEN bool validate_Rwstat(struct _validate_ctx *UNUSED(ctx)) {
@@ -816,12 +822,14 @@ static FLATTEN void unmarshal_Tstat(struct _unmarshal_ctx *ctx, struct lib9p_msg
static FLATTEN void unmarshal_Rstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Rstat *out) {
memset(out, 0, sizeof(*out));
+ ctx->net_offset += 2;
unmarshal_stat(ctx, &out->stat);
}
static FLATTEN void unmarshal_Twstat(struct _unmarshal_ctx *ctx, struct lib9p_msg_Twstat *out) {
memset(out, 0, sizeof(*out));
unmarshal_4(ctx, &out->fid);
+ ctx->net_offset += 2;
unmarshal_stat(ctx, &out->stat);
}
@@ -946,11 +954,10 @@ static ALWAYS_INLINE bool marshal_qid(struct _marshal_ctx *ctx, struct lib9p_qid
}
static ALWAYS_INLINE bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_stat *val) {
- uint32_t size_offset = ctx->net_offset;
- return (ctx->net_offset + 2 > ctx->ctx->max_msg_size
- ? _marshal_too_large(ctx)
- : ({ ctx->net_offset += 2; false; }))
- || marshal_2(ctx, &val->kern_type)
+ uint32_t _stat_size_offset;
+ uint32_t _kern_type_offset;
+ return ({ _stat_size_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); })
+ || ({ _kern_type_offset = ctx->net_offset; marshal_2(ctx, &val->kern_type); })
|| marshal_4(ctx, &val->kern_dev)
|| marshal_qid(ctx, &val->file_qid)
|| marshal_dm(ctx, &val->file_mode)
@@ -965,10 +972,7 @@ static ALWAYS_INLINE bool marshal_stat(struct _marshal_ctx *ctx, struct lib9p_st
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_owner_n_uid) )
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_owner_n_gid) )
|| ( (ctx->ctx->version==LIB9P_VER_9P2000_u) && marshal_4(ctx, &val->file_last_modified_n_uid) )
- || ((ctx->net_offset - (size_offset+2) > UINT16_MAX)
- ? lib9p_error(ctx->ctx, LINUX_ERANGE, "stat object too large")
- : ({ encode_u16le((uint16_t)(ctx->net_offset - (size_offset+2)), &ctx->net_bytes[size_offset]);
- false; }));
+ || ({ encode_u16le( ctx->net_offset - _kern_type_offset, &ctx->net_bytes[_stat_size_offset]); false; });
}
static ALWAYS_INLINE bool marshal_o(struct _marshal_ctx *ctx, lib9p_o_t *val) {
@@ -1106,12 +1110,20 @@ static FLATTEN bool marshal_Tstat(struct _marshal_ctx *ctx, struct lib9p_msg_Tst
}
static FLATTEN bool marshal_Rstat(struct _marshal_ctx *ctx, struct lib9p_msg_Rstat *val) {
- return marshal_stat(ctx, &val->stat);
+ uint32_t _nstat_offset;
+ uint32_t _stat_offset;
+ return ({ _nstat_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); })
+ || ({ _stat_offset = ctx->net_offset; marshal_stat(ctx, &val->stat); })
+ || ({ encode_u16le( ctx->net_offset - _stat_offset, &ctx->net_bytes[_nstat_offset]); false; });
}
static FLATTEN bool marshal_Twstat(struct _marshal_ctx *ctx, struct lib9p_msg_Twstat *val) {
+ uint32_t _nstat_offset;
+ uint32_t _stat_offset;
return marshal_4(ctx, &val->fid)
- || marshal_stat(ctx, &val->stat);
+ || ({ _nstat_offset = ctx->net_offset; ({ ctx->net_offset += 2; false; }); })
+ || ({ _stat_offset = ctx->net_offset; marshal_stat(ctx, &val->stat); })
+ || ({ encode_u16le( ctx->net_offset - _stat_offset, &ctx->net_bytes[_nstat_offset]); false; });
}
static FLATTEN bool marshal_Rwstat(struct _marshal_ctx *UNUSED(ctx), struct lib9p_msg_Rwstat *UNUSED(val)) {