From 334d83053a593e0adeea7f958a9811381fb458fc Mon Sep 17 00:00:00 2001 From: Piotr Pawlow Date: Fri, 11 Aug 2017 15:31:56 +0200 Subject: btrfs-progs: image: add a function to check if generated filename suffix is valid Author: Piotr Pawlow Signed-off-by: David Sterba --- image/main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'image') diff --git a/image/main.c b/image/main.c index b7e06885..c743cb4d 100644 --- a/image/main.c +++ b/image/main.c @@ -431,6 +431,22 @@ static void find_collision_calc_suffix(unsigned long current_crc, 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) { unsigned long checksum; -- cgit v1.2.3