Early error check in golang struct reading

avoids a timeout on malformed input found by fuzzing
This commit is contained in:
Philippe Antoine 2021-03-15 09:26:39 +01:00 committed by Yuxuan 'fishy' Wang
parent cc70b4e89a
commit 62beb6751d

View File

@ -122,11 +122,14 @@ func Skip(ctx context.Context, self TProtocol, fieldType TType, maxDepth int) (e
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
}