backup/chunk_store: verify chunk file names
get_chunk_iterator() should skip over files which aren't an actual chunk Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
		@ -229,7 +229,24 @@ impl ChunkStore {
 | 
				
			|||||||
                Ok(iter) => Some(iter),
 | 
					                Ok(iter) => Some(iter),
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        })
 | 
					        })
 | 
				
			||||||
        .flatten())
 | 
					        .flatten()
 | 
				
			||||||
 | 
					        .filter(|entry| {
 | 
				
			||||||
 | 
					            // Check that the file name is actually a hash! (64 hex digits)
 | 
				
			||||||
 | 
					            let entry = match entry {
 | 
				
			||||||
 | 
					                Err(_) => return true, // pass errors onwards
 | 
				
			||||||
 | 
					                Ok(ref entry) => entry,
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					            let bytes = entry.file_name().to_bytes();
 | 
				
			||||||
 | 
					            if bytes.len() != 64 {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            for b in bytes {
 | 
				
			||||||
 | 
					                if !b.is_ascii_hexdigit() {
 | 
				
			||||||
 | 
					                    return false;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            true
 | 
				
			||||||
 | 
					        }))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn sweep_unused_chunks(&self, status: &mut GarbageCollectionStatus) -> Result<(), Error> {
 | 
					    pub fn sweep_unused_chunks(&self, status: &mut GarbageCollectionStatus) -> Result<(), Error> {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user