aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encoding.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-11-22 10:37:05 +0000
committerDmitry Vyukov <dvyukov@google.com>2022-11-22 11:48:19 +0100
commit1c8e10bcebe7f39ca238a5dfbd1bd92c9faa39b8 (patch)
treee75bc132bcfd3e2613420f779efe33ea8c31680a /prog/encoding.go
parent1c576c232f825266983096180b3603005edc458e (diff)
prog: handle broken base64 strings
Currently it can fail if there's never a closing quote. Add a test to verify this behavior.
Diffstat (limited to 'prog/encoding.go')
-rw-r--r--prog/encoding.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/prog/encoding.go b/prog/encoding.go
index 33983fb47..5c4be432e 100644
--- a/prog/encoding.go
+++ b/prog/encoding.go
@@ -978,15 +978,15 @@ func (p *parser) deserializeData() ([]byte, bool, error) {
// Read Base64 data.
p.consume()
var rawData []byte
- for p.Char() != '"' {
+ for !p.EOF() && p.Char() != '"' {
v := p.consume()
rawData = append(rawData, v)
}
+ p.Parse('"')
decoded, err := DecodeB64(rawData)
if err != nil {
return nil, false, fmt.Errorf("data arg is corrupt: %v", err)
}
- p.Parse('"')
return decoded, true, nil
}
val := ""