Early error check in golang struct reading
avoids a timeout on malformed input found by fuzzing
diff --git a/lib/go/thrift/protocol.go b/lib/go/thrift/protocol.go
index 0a69bd4..4768c8f 100644
--- a/lib/go/thrift/protocol.go
+++ b/lib/go/thrift/protocol.go
@@ -122,11 +122,14 @@
return err
}
for {
- _, typeId, _, _ := self.ReadFieldBegin(ctx)
+ _, typeId, _, err := self.ReadFieldBegin(ctx)
+ if err != nil {
+ return err
+ }
if typeId == STOP {
break
}
- err := Skip(ctx, self, typeId, maxDepth-1)
+ err = Skip(ctx, self, typeId, maxDepth-1)
if err != nil {
return err
}