btrfs-progs: image: add a function to check if generated filename suffix is valid

Author: Piotr Pawlow <pp@siedziba.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Piotr Pawlow 2017-08-11 15:31:56 +02:00 committed by David Sterba
parent c859336f47
commit 334d83053a
1 changed files with 16 additions and 0 deletions

View File

@ -431,6 +431,22 @@ static void find_collision_calc_suffix(unsigned long current_crc,
suffix[i] = (desired_crc >> i * 8) & 0xFF; suffix[i] = (desired_crc >> i * 8) & 0xFF;
} }
/*
* Check if suffix is valid according to our file name conventions
*/
static int find_collision_is_suffix_valid(const char *suffix)
{
int i;
char c;
for (i = 0; i < 4; i++) {
c = suffix[i];
if (c < ' ' || c > 126 || c == '/')
return 0;
}
return 1;
}
static int find_collision_brute_force(struct name *val, u32 name_len) static int find_collision_brute_force(struct name *val, u32 name_len)
{ {
unsigned long checksum; unsigned long checksum;