golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.64k stars 1.58k forks source link

Unreachable code #1573

Open VoroninArtemii opened 8 months ago

VoroninArtemii commented 8 months ago

Issue Description

The condition will always be false, so the block will never be executed. Constant value: https://github.com/golang/protobuf/blob/5d5e8c018a13017f9d5b8bf4fad64aaa42a87308/proto/text_decode.go#L22 Blocks IF: https://github.com/golang/protobuf/blob/5d5e8c018a13017f9d5b8bf4fad64aaa42a87308/proto/text_decode.go#L33-L35 https://github.com/golang/protobuf/blob/5d5e8c018a13017f9d5b8bf4fad64aaa42a87308/proto/text_decode.go#L51-L59 And this case is in other file: https://github.com/golang/protobuf/blob/5d5e8c018a13017f9d5b8bf4fad64aaa42a87308/proto/text_encode.go#L23 https://github.com/golang/protobuf/blob/5d5e8c018a13017f9d5b8bf4fad64aaa42a87308/proto/text_encode.go#L54-L70 Similar case is in other files: https://github.com/golang/protobuf/blob/5d5e8c018a13017f9d5b8bf4fad64aaa42a87308/jsonpb/decode.go#L25 https://github.com/golang/protobuf/blob/5d5e8c018a13017f9d5b8bf4fad64aaa42a87308/jsonpb/decode.go#L97-L126 https://github.com/golang/protobuf/blob/5d5e8c018a13017f9d5b8bf4fad64aaa42a87308/jsonpb/encode.go#L26 https://github.com/golang/protobuf/blob/5d5e8c018a13017f9d5b8bf4fad64aaa42a87308/jsonpb/encode.go#L97-L108

Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE. Author A. Voronin.

puellanivis commented 8 months ago

The wrapTextUnmarshalV2 value is part of the Google-internal use of this package, and is not always false for them.

Since Google uses a duplicate of this code internally, there’s some things like this.