Check b.len() < Self::FIXED_SIZE, not b.len() < 4
The original thinking was that if len(b) < FIXED_SIZE, then that would be picked up later by the "invalid member length" check. In that case, this only really *needs* to make sure that the check after this for "wrong fourcc" wouldn't fail. But if len(b) < FIXED_SIZE, it really is an invalid size, and should get that error message before even starting to validate its other qualities.
This commit is contained in:
		@@ -96,7 +96,7 @@ impl DHTSchemaSMPL {
 | 
			
		||||
impl TryFrom<&[u8]> for DHTSchemaSMPL {
 | 
			
		||||
    type Error = VeilidAPIError;
 | 
			
		||||
    fn try_from(b: &[u8]) -> Result<Self, Self::Error> {
 | 
			
		||||
        if b.len() < 4 {
 | 
			
		||||
        if b.len() < Self::FIXED_SIZE {
 | 
			
		||||
            apibail_generic!("invalid size");
 | 
			
		||||
        }
 | 
			
		||||
        if &b[0..4] != &Self::FCC {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user