From 0936819b9f980bde731cb6191677f9aa2cbfd9aa Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 17 Jan 2024 11:37:02 +0100 Subject: prog: test len calculation of structs with conditions --- prog/size_test.go | 8 ++++++++ sys/test/test.txt | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/prog/size_test.go b/prog/size_test.go index 2f7dc9ce2..7db32442f 100644 --- a/prog/size_test.go +++ b/prog/size_test.go @@ -178,5 +178,13 @@ test$length30(&(0x7f0000000000)=ANY=[@ANYBLOB="11"], 0x42, &(0x7f0000000000)=0x4 In: "test$length34(&(0x7f0000000000)={[0x0, 0x0, 0x0, 0x0], &(0x7f0000000040)=@u1=0x0})", Out: "test$length34(&(0x7f0000000000)={[0x0, 0x0, 0x0, 0x0], &(0x7f0000000040)=@u1=0x4})", }, + { + In: "test$length35(&(0x7f0000000000)={0x0, {0x5, @void}})", + Out: "test$length35(&(0x7f0000000000)={0x4, {0x5}})", + }, + { + In: "test$length35(&(0x7f0000000000)={0x0, {0x1, @value=0x5}})", + Out: "test$length35(&(0x7f0000000000)={0x8, {0x1, @value=0x5}})", + }, }) } diff --git a/sys/test/test.txt b/sys/test/test.txt index 788eb8484..c59b9d3d3 100644 --- a/sys/test/test.txt +++ b/sys/test/test.txt @@ -517,6 +517,18 @@ parent_union [ test$length34(a0 ptr[in, parent_union_struct]) +struct_with_condition { + f1 int32 + f2 int32 (if[value[f1] == 0x1]) +} [packed] + +len_of_cond_struct { + f1 len[f2, int32] + f2 struct_with_condition +} + +test$length35(a0 ptr[in, len_of_cond_struct]) + # Big endian test$end0(a0 ptr[in, syz_end_int_struct]) -- cgit mrf-deployment