From 1360be3b26a4fe8a3ece98440df5a82253ac23ba Mon Sep 17 00:00:00 2001 From: Hrutvik Kanabar Date: Tue, 25 Oct 2022 10:14:37 +0000 Subject: prog: introduce new Base64 syntax for data The new "$..." syntax is read as a Base64 encoding binary data. Note that users cannot specify the size of the Base64 syntax using the `"..."/` notation. When serialising programs to human-readable form, only compressed types (determined by `IsCompressed()`) are represented using the new Base64 notation. Also add a couple of serialisation tests, checking behaviour for compressed and non-compressed types. --- prog/encoding_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'prog/encoding_test.go') diff --git a/prog/encoding_test.go b/prog/encoding_test.go index 4717c402b..4cb836922 100644 --- a/prog/encoding_test.go +++ b/prog/encoding_test.go @@ -36,7 +36,7 @@ func TestSerializeData(t *testing.T) { if !p.Scan() { t.Fatalf("parser does not scan") } - data1, err := p.deserializeData() + data1, _, err := p.deserializeData() if err != nil { t.Fatalf("failed to deserialize %q -> %s: %v", data, buf.Bytes(), err) } @@ -344,6 +344,13 @@ func TestSerializeDeserialize(t *testing.T) { In: `serialize1(&(0x7f0000000000)="0000000000000000", 0x8)`, Out: `serialize1(&(0x7f0000000000)=""/8, 0x8)`, }, + { + In: `serialize2(&(0x7f0000000000)="$c3l6a2FsbGVy")`, + Out: `serialize2(&(0x7f0000000000)='syzkaller')`, + }, + { + In: `serialize3(&(0x7f0000000000)="$eJwqrqzKTszJSS0CBAAA//8TyQPi")`, + }, }) } -- cgit mrf-deployment