goprotobuf: Better error handling for invalid input that mentions tag 0.
R=r
CC=golang-dev
http://codereview.appspot.com/5653064
diff --git a/proto/decode.go b/proto/decode.go
index 66f7a05..836227e 100644
--- a/proto/decode.go
+++ b/proto/decode.go
@@ -348,6 +348,9 @@
return ErrWrongType
}
tag := int(u >> 3)
+ if tag <= 0 {
+ return fmt.Errorf("proto: illegal tag %d", tag)
+ }
fieldnum, ok := prop.tags[tag]
if !ok {
// Maybe it's an extension?
@@ -365,7 +368,7 @@
p := prop.Prop[fieldnum]
if p.dec == nil {
- fmt.Fprintf(os.Stderr, "no protobuf decoder for %s.%s\n", t, st.Field(fieldnum).Name)
+ fmt.Fprintf(os.Stderr, "proto: no protobuf decoder for %s.%s\n", t, st.Field(fieldnum).Name)
continue
}
dec := p.dec