mirror of
				https://github.com/pion/webrtc.git
				synced 2025-10-31 18:52:55 +08:00 
			
		
		
		
	RTCP: test for unmarshaling nil packet
This commit is contained in:
		 Max Hawkins
					Max Hawkins
				
			
				
					committed by
					
						 Michiel De Backker
						Michiel De Backker
					
				
			
			
				
	
			
			
			 Michiel De Backker
						Michiel De Backker
					
				
			
						parent
						
							74e2d1e3de
						
					
				
				
					commit
					894296d9ab
				
			| @@ -46,6 +46,7 @@ const ( | |||||||
| var ( | var ( | ||||||
| 	errInvalidVersion     = errors.New("invalid version") | 	errInvalidVersion     = errors.New("invalid version") | ||||||
| 	errInvalidReportCount = errors.New("invalid report count") | 	errInvalidReportCount = errors.New("invalid report count") | ||||||
|  | 	errHeaderTooShort     = errors.New("rtcp header too short") | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // Marshal encodes the Header in binary | // Marshal encodes the Header in binary | ||||||
| @@ -83,7 +84,7 @@ func (h Header) Marshal() ([]byte, error) { | |||||||
| // Unmarshal decodes the Header from binary | // Unmarshal decodes the Header from binary | ||||||
| func (h *Header) Unmarshal(rawPacket []byte) error { | func (h *Header) Unmarshal(rawPacket []byte) error { | ||||||
| 	if len(rawPacket) < headerLength { | 	if len(rawPacket) < headerLength { | ||||||
| 		return errors.Errorf("RTCP header size insufficient; %d < %d", len(rawPacket), headerLength) | 		return errHeaderTooShort | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/* | 	/* | ||||||
|   | |||||||
| @@ -29,6 +29,14 @@ func TestHeaderUnmarshal(t *testing.T) { | |||||||
| 		t.Fatalf("Unmarshal: got %#v, want %#v", got, want) | 		t.Fatalf("Unmarshal: got %#v, want %#v", got, want) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func TestHeaderUnmarshalNil(t *testing.T) { | ||||||
|  | 	var header Header | ||||||
|  | 	err := header.Unmarshal(nil) | ||||||
|  | 	if got, want := err, errHeaderTooShort; got != want { | ||||||
|  | 		t.Fatalf("unmarshal nil header: err = %v, want %v", got, want) | ||||||
|  | 	} | ||||||
|  | } | ||||||
| func TestHeaderRoundTrip(t *testing.T) { | func TestHeaderRoundTrip(t *testing.T) { | ||||||
| 	for _, test := range []struct { | 	for _, test := range []struct { | ||||||
| 		Name      string | 		Name      string | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user