Browse Source

Merge pull request #834 from unihorn/100

fix(raft/protobuf): avoid panic on unexcepted data
Xiang Li 11 years ago
parent
commit
79c650d900

+ 26 - 7
third_party/github.com/goraft/raft/protobuf/append_entries_request.pb.go

@@ -2,6 +2,23 @@
 // source: append_entries_request.proto
 // DO NOT EDIT!
 
+/*
+	Package protobuf is a generated protocol buffer package.
+
+	It is generated from these files:
+		append_entries_request.proto
+		append_entries_responses.proto
+		log_entry.proto
+		request_vote_request.proto
+		request_vote_responses.proto
+		snapshot_recovery_request.proto
+		snapshot_recovery_response.proto
+		snapshot_request.proto
+		snapshot_response.proto
+
+	It has these top-level messages:
+		AppendEntriesRequest
+*/
 package protobuf
 
 import proto "github.com/coreos/etcd/third_party/code.google.com/p/gogoprotobuf/proto"
@@ -110,7 +127,7 @@ func (m *AppendEntriesRequest) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto2.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -127,7 +144,7 @@ func (m *AppendEntriesRequest) Unmarshal(data []byte) error {
 			m.Term = &v
 		case 2:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto2.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -144,7 +161,7 @@ func (m *AppendEntriesRequest) Unmarshal(data []byte) error {
 			m.PrevLogIndex = &v
 		case 3:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto2.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -161,7 +178,7 @@ func (m *AppendEntriesRequest) Unmarshal(data []byte) error {
 			m.PrevLogTerm = &v
 		case 4:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto2.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -178,7 +195,7 @@ func (m *AppendEntriesRequest) Unmarshal(data []byte) error {
 			m.CommitIndex = &v
 		case 5:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto2.ErrWrongType
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -201,7 +218,7 @@ func (m *AppendEntriesRequest) Unmarshal(data []byte) error {
 			index = postIndex
 		case 6:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto2.ErrWrongType
 			}
 			var msglen int
 			for shift := uint(0); ; shift += 7 {
@@ -236,6 +253,9 @@ func (m *AppendEntriesRequest) Unmarshal(data []byte) error {
 			if err != nil {
 				return err
 			}
+			if (index + skippy) > l {
+				return io1.ErrUnexpectedEOF
+			}
 			m.XXX_unrecognized = append(m.XXX_unrecognized, data[index:index+skippy]...)
 			index += skippy
 		}
@@ -309,7 +329,6 @@ func sovAppendEntriesRequest(x uint64) (n int) {
 }
 func sozAppendEntriesRequest(x uint64) (n int) {
 	return sovAppendEntriesRequest(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-	return sovAppendEntriesRequest(uint64((x << 1) ^ uint64((int64(x) >> 63))))
 }
 func NewPopulatedAppendEntriesRequest(r randyAppendEntriesRequest, easy bool) *AppendEntriesRequest {
 	this := &AppendEntriesRequest{}

+ 7 - 5
third_party/github.com/goraft/raft/protobuf/append_entries_responses.pb.go

@@ -94,7 +94,7 @@ func (m *AppendEntriesResponse) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto4.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -111,7 +111,7 @@ func (m *AppendEntriesResponse) Unmarshal(data []byte) error {
 			m.Term = &v
 		case 2:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto4.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -128,7 +128,7 @@ func (m *AppendEntriesResponse) Unmarshal(data []byte) error {
 			m.Index = &v
 		case 3:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto4.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -145,7 +145,7 @@ func (m *AppendEntriesResponse) Unmarshal(data []byte) error {
 			m.CommitIndex = &v
 		case 4:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto4.ErrWrongType
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -175,6 +175,9 @@ func (m *AppendEntriesResponse) Unmarshal(data []byte) error {
 			if err != nil {
 				return err
 			}
+			if (index + skippy) > l {
+				return io2.ErrUnexpectedEOF
+			}
 			m.XXX_unrecognized = append(m.XXX_unrecognized, data[index:index+skippy]...)
 			index += skippy
 		}
@@ -236,7 +239,6 @@ func sovAppendEntriesResponses(x uint64) (n int) {
 }
 func sozAppendEntriesResponses(x uint64) (n int) {
 	return sovAppendEntriesResponses(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-	return sovAppendEntriesResponses(uint64((x << 1) ^ uint64((int64(x) >> 63))))
 }
 func NewPopulatedAppendEntriesResponse(r randyAppendEntriesResponses, easy bool) *AppendEntriesResponse {
 	this := &AppendEntriesResponse{}

+ 7 - 5
third_party/github.com/goraft/raft/protobuf/log_entry.pb.go

@@ -94,7 +94,7 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -111,7 +111,7 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 			m.Index = &v
 		case 2:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -128,7 +128,7 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 			m.Term = &v
 		case 3:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -151,7 +151,7 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 			index = postIndex
 		case 4:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto.ErrWrongType
 			}
 			var byteLen int
 			for shift := uint(0); ; shift += 7 {
@@ -185,6 +185,9 @@ func (m *LogEntry) Unmarshal(data []byte) error {
 			if err != nil {
 				return err
 			}
+			if (index + skippy) > l {
+				return io.ErrUnexpectedEOF
+			}
 			m.XXX_unrecognized = append(m.XXX_unrecognized, data[index:index+skippy]...)
 			index += skippy
 		}
@@ -248,7 +251,6 @@ func sovLogEntry(x uint64) (n int) {
 }
 func sozLogEntry(x uint64) (n int) {
 	return sovLogEntry(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-	return sovLogEntry(uint64((x << 1) ^ uint64((int64(x) >> 63))))
 }
 func NewPopulatedLogEntry(r randyLogEntry, easy bool) *LogEntry {
 	this := &LogEntry{}

+ 7 - 5
third_party/github.com/goraft/raft/protobuf/request_vote_request.pb.go

@@ -94,7 +94,7 @@ func (m *RequestVoteRequest) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto6.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -111,7 +111,7 @@ func (m *RequestVoteRequest) Unmarshal(data []byte) error {
 			m.Term = &v
 		case 2:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto6.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -128,7 +128,7 @@ func (m *RequestVoteRequest) Unmarshal(data []byte) error {
 			m.LastLogIndex = &v
 		case 3:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto6.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -145,7 +145,7 @@ func (m *RequestVoteRequest) Unmarshal(data []byte) error {
 			m.LastLogTerm = &v
 		case 4:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto6.ErrWrongType
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -180,6 +180,9 @@ func (m *RequestVoteRequest) Unmarshal(data []byte) error {
 			if err != nil {
 				return err
 			}
+			if (index + skippy) > l {
+				return io3.ErrUnexpectedEOF
+			}
 			m.XXX_unrecognized = append(m.XXX_unrecognized, data[index:index+skippy]...)
 			index += skippy
 		}
@@ -242,7 +245,6 @@ func sovRequestVoteRequest(x uint64) (n int) {
 }
 func sozRequestVoteRequest(x uint64) (n int) {
 	return sovRequestVoteRequest(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-	return sovRequestVoteRequest(uint64((x << 1) ^ uint64((int64(x) >> 63))))
 }
 func NewPopulatedRequestVoteRequest(r randyRequestVoteRequest, easy bool) *RequestVoteRequest {
 	this := &RequestVoteRequest{}

+ 5 - 3
third_party/github.com/goraft/raft/protobuf/request_vote_responses.pb.go

@@ -78,7 +78,7 @@ func (m *RequestVoteResponse) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto8.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -95,7 +95,7 @@ func (m *RequestVoteResponse) Unmarshal(data []byte) error {
 			m.Term = &v
 		case 2:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto8.ErrWrongType
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -125,6 +125,9 @@ func (m *RequestVoteResponse) Unmarshal(data []byte) error {
 			if err != nil {
 				return err
 			}
+			if (index + skippy) > l {
+				return io4.ErrUnexpectedEOF
+			}
 			m.XXX_unrecognized = append(m.XXX_unrecognized, data[index:index+skippy]...)
 			index += skippy
 		}
@@ -178,7 +181,6 @@ func sovRequestVoteResponses(x uint64) (n int) {
 }
 func sozRequestVoteResponses(x uint64) (n int) {
 	return sovRequestVoteResponses(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-	return sovRequestVoteResponses(uint64((x << 1) ^ uint64((int64(x) >> 63))))
 }
 func NewPopulatedRequestVoteResponse(r randyRequestVoteResponses, easy bool) *RequestVoteResponse {
 	this := &RequestVoteResponse{}

+ 13 - 8
third_party/github.com/goraft/raft/protobuf/snapshot_recovery_request.pb.go

@@ -125,7 +125,7 @@ func (m *SnapshotRecoveryRequest) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto10.ErrWrongType
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -148,7 +148,7 @@ func (m *SnapshotRecoveryRequest) Unmarshal(data []byte) error {
 			index = postIndex
 		case 2:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto10.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -165,7 +165,7 @@ func (m *SnapshotRecoveryRequest) Unmarshal(data []byte) error {
 			m.LastIndex = &v
 		case 3:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto10.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -182,7 +182,7 @@ func (m *SnapshotRecoveryRequest) Unmarshal(data []byte) error {
 			m.LastTerm = &v
 		case 4:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto10.ErrWrongType
 			}
 			var msglen int
 			for shift := uint(0); ; shift += 7 {
@@ -205,7 +205,7 @@ func (m *SnapshotRecoveryRequest) Unmarshal(data []byte) error {
 			index = postIndex
 		case 5:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto10.ErrWrongType
 			}
 			var byteLen int
 			for shift := uint(0); ; shift += 7 {
@@ -239,6 +239,9 @@ func (m *SnapshotRecoveryRequest) Unmarshal(data []byte) error {
 			if err != nil {
 				return err
 			}
+			if (index + skippy) > l {
+				return io5.ErrUnexpectedEOF
+			}
 			m.XXX_unrecognized = append(m.XXX_unrecognized, data[index:index+skippy]...)
 			index += skippy
 		}
@@ -266,7 +269,7 @@ func (m *SnapshotRecoveryRequest_Peer) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto10.ErrWrongType
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -289,7 +292,7 @@ func (m *SnapshotRecoveryRequest_Peer) Unmarshal(data []byte) error {
 			index = postIndex
 		case 2:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto10.ErrWrongType
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -324,6 +327,9 @@ func (m *SnapshotRecoveryRequest_Peer) Unmarshal(data []byte) error {
 			if err != nil {
 				return err
 			}
+			if (index + skippy) > l {
+				return io5.ErrUnexpectedEOF
+			}
 			m.XXX_unrecognized = append(m.XXX_unrecognized, data[index:index+skippy]...)
 			index += skippy
 		}
@@ -422,7 +428,6 @@ func sovSnapshotRecoveryRequest(x uint64) (n int) {
 }
 func sozSnapshotRecoveryRequest(x uint64) (n int) {
 	return sovSnapshotRecoveryRequest(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-	return sovSnapshotRecoveryRequest(uint64((x << 1) ^ uint64((int64(x) >> 63))))
 }
 func NewPopulatedSnapshotRecoveryRequest(r randySnapshotRecoveryRequest, easy bool) *SnapshotRecoveryRequest {
 	this := &SnapshotRecoveryRequest{}

+ 6 - 4
third_party/github.com/goraft/raft/protobuf/snapshot_recovery_response.pb.go

@@ -86,7 +86,7 @@ func (m *SnapshotRecoveryResponse) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto12.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -103,7 +103,7 @@ func (m *SnapshotRecoveryResponse) Unmarshal(data []byte) error {
 			m.Term = &v
 		case 2:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto12.ErrWrongType
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -121,7 +121,7 @@ func (m *SnapshotRecoveryResponse) Unmarshal(data []byte) error {
 			m.Success = &b
 		case 3:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto12.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -150,6 +150,9 @@ func (m *SnapshotRecoveryResponse) Unmarshal(data []byte) error {
 			if err != nil {
 				return err
 			}
+			if (index + skippy) > l {
+				return io6.ErrUnexpectedEOF
+			}
 			m.XXX_unrecognized = append(m.XXX_unrecognized, data[index:index+skippy]...)
 			index += skippy
 		}
@@ -207,7 +210,6 @@ func sovSnapshotRecoveryResponse(x uint64) (n int) {
 }
 func sozSnapshotRecoveryResponse(x uint64) (n int) {
 	return sovSnapshotRecoveryResponse(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-	return sovSnapshotRecoveryResponse(uint64((x << 1) ^ uint64((int64(x) >> 63))))
 }
 func NewPopulatedSnapshotRecoveryResponse(r randySnapshotRecoveryResponse, easy bool) *SnapshotRecoveryResponse {
 	this := &SnapshotRecoveryResponse{}

+ 6 - 4
third_party/github.com/goraft/raft/protobuf/snapshot_request.pb.go

@@ -86,7 +86,7 @@ func (m *SnapshotRequest) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 2 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto14.ErrWrongType
 			}
 			var stringLen uint64
 			for shift := uint(0); ; shift += 7 {
@@ -109,7 +109,7 @@ func (m *SnapshotRequest) Unmarshal(data []byte) error {
 			index = postIndex
 		case 2:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto14.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -126,7 +126,7 @@ func (m *SnapshotRequest) Unmarshal(data []byte) error {
 			m.LastIndex = &v
 		case 3:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto14.ErrWrongType
 			}
 			var v uint64
 			for shift := uint(0); ; shift += 7 {
@@ -155,6 +155,9 @@ func (m *SnapshotRequest) Unmarshal(data []byte) error {
 			if err != nil {
 				return err
 			}
+			if (index + skippy) > l {
+				return io7.ErrUnexpectedEOF
+			}
 			m.XXX_unrecognized = append(m.XXX_unrecognized, data[index:index+skippy]...)
 			index += skippy
 		}
@@ -213,7 +216,6 @@ func sovSnapshotRequest(x uint64) (n int) {
 }
 func sozSnapshotRequest(x uint64) (n int) {
 	return sovSnapshotRequest(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-	return sovSnapshotRequest(uint64((x << 1) ^ uint64((int64(x) >> 63))))
 }
 func NewPopulatedSnapshotRequest(r randySnapshotRequest, easy bool) *SnapshotRequest {
 	this := &SnapshotRequest{}

+ 4 - 2
third_party/github.com/goraft/raft/protobuf/snapshot_response.pb.go

@@ -70,7 +70,7 @@ func (m *SnapshotResponse) Unmarshal(data []byte) error {
 		switch fieldNum {
 		case 1:
 			if wireType != 0 {
-				return proto.ErrWrongType
+				return code_google_com_p_gogoprotobuf_proto16.ErrWrongType
 			}
 			var v int
 			for shift := uint(0); ; shift += 7 {
@@ -100,6 +100,9 @@ func (m *SnapshotResponse) Unmarshal(data []byte) error {
 			if err != nil {
 				return err
 			}
+			if (index + skippy) > l {
+				return io8.ErrUnexpectedEOF
+			}
 			m.XXX_unrecognized = append(m.XXX_unrecognized, data[index:index+skippy]...)
 			index += skippy
 		}
@@ -149,7 +152,6 @@ func sovSnapshotResponse(x uint64) (n int) {
 }
 func sozSnapshotResponse(x uint64) (n int) {
 	return sovSnapshotResponse(uint64((x << 1) ^ uint64((int64(x) >> 63))))
-	return sovSnapshotResponse(uint64((x << 1) ^ uint64((int64(x) >> 63))))
 }
 func NewPopulatedSnapshotResponse(r randySnapshotResponse, easy bool) *SnapshotResponse {
 	this := &SnapshotResponse{}