From c9dc59eb90144b9935a143353eb38d8eef937cc1 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 18 Feb 2019 12:40:11 +1100 Subject: [PATCH] properly detect period as last character in filename --- contrib/dlz/drivers/dlz_filesystem_driver.c | 4 ++-- contrib/dlz/modules/filesystem/dlz_filesystem_dynamic.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/dlz/drivers/dlz_filesystem_driver.c b/contrib/dlz/drivers/dlz_filesystem_driver.c index 97186e4433..a136e65028 100644 --- a/contrib/dlz/drivers/dlz_filesystem_driver.c +++ b/contrib/dlz/drivers/dlz_filesystem_driver.c @@ -113,10 +113,10 @@ is_safe(const char *input) { if (i == 0) return (false); /* '..', two dots together is not allowed. */ - else if (input[i-1] == '.') + if (input[i-1] == '.') return (false); /* '.' is not allowed as last char */ - if (i == len) + if (i == len - 1) return (false); /* only 1 dot in ok location, continue at next char */ continue; diff --git a/contrib/dlz/modules/filesystem/dlz_filesystem_dynamic.c b/contrib/dlz/modules/filesystem/dlz_filesystem_dynamic.c index 4ff2b31f24..494bd1805a 100644 --- a/contrib/dlz/modules/filesystem/dlz_filesystem_dynamic.c +++ b/contrib/dlz/modules/filesystem/dlz_filesystem_dynamic.c @@ -106,10 +106,10 @@ is_safe(const char *input) { if (i == 0) return (false); /* '..', two dots together is not allowed. */ - else if (input[i-1] == '.') + if (input[i-1] == '.') return (false); /* '.' is not allowed as last char */ - if (i == len) + if (i == len - 1) return (false); /* only 1 dot in ok location, continue at next char */ continue;