summaryrefslogtreecommitdiff
path: root/lib9p/9p.generated.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-03 13:09:43 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-03 13:09:43 -0600
commitbc045fc7b082b426d7fc165fd07f8184ba2c7ef2 (patch)
tree79c06e18221e768f2b120599bcef5f4158ea5077 /lib9p/9p.generated.c
parentf401359d87f3375efdd39801652cc18574240049 (diff)
lib9p: Allow specifying a maximum value for an atom in *.txt
Diffstat (limited to 'lib9p/9p.generated.c')
-rw-r--r--lib9p/9p.generated.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib9p/9p.generated.c b/lib9p/9p.generated.c
index 387af79..0259e23 100644
--- a/lib9p/9p.generated.c
+++ b/lib9p/9p.generated.c
@@ -311,11 +311,8 @@ static ALWAYS_INLINE bool _validate_size_host(struct _validate_ctx *ctx, size_t
}
static ALWAYS_INLINE bool _validate_list(struct _validate_ctx *ctx,
- size_t cnt, size_t max,
+ size_t cnt,
_validate_fn_t item_fn, size_t item_host_size) {
- if (max && cnt > max)
- return lib9p_errorf(ctx->ctx, LINUX_EBADMSG, "list size is too large (%zu > %zu)",
- cnt, max);
for (size_t i = 0; i < cnt; i++)
if (_validate_size_host(ctx, item_host_size) || item_fn(ctx))
return true;
@@ -464,12 +461,20 @@ static FLATTEN bool validate_Twalk(struct _validate_ctx *ctx) {
return validate_4(ctx)
|| validate_4(ctx)
|| validate_2(ctx)
- || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), 16, validate_s, sizeof(struct lib9p_s));
+ || (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_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)
- || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), 16, validate_qid, sizeof(struct lib9p_qid));
+ || (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_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_qid, sizeof(struct lib9p_qid));
}
static FLATTEN bool validate_Topen(struct _validate_ctx *ctx) {
@@ -558,7 +563,7 @@ static FLATTEN bool validate_Rsession(struct _validate_ctx *UNUSED(ctx)) {
static FLATTEN bool validate_Tsread(struct _validate_ctx *ctx) {
return validate_4(ctx)
|| validate_2(ctx)
- || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), 0, validate_s, sizeof(struct lib9p_s));
+ || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s));
}
static FLATTEN bool validate_Rsread(struct _validate_ctx *ctx) {
@@ -568,7 +573,7 @@ static FLATTEN bool validate_Rsread(struct _validate_ctx *ctx) {
static FLATTEN bool validate_Tswrite(struct _validate_ctx *ctx) {
return validate_4(ctx)
|| validate_2(ctx)
- || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), 0, validate_s, sizeof(struct lib9p_s))
+ || _validate_list(ctx, decode_u16le(&ctx->net_bytes[ctx->net_offset-2]), validate_s, sizeof(struct lib9p_s))
|| validate_d(ctx);
}