From 21d6e9a91ec71d0fd36a6cf9bfb3435d4df708be 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 (cherry picked from commit c9dc59eb90144b9935a143353eb38d8eef937cc1) --- 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 a8af12d983..879cb67098 100644 --- a/contrib/dlz/drivers/dlz_filesystem_driver.c +++ b/contrib/dlz/drivers/dlz_filesystem_driver.c @@ -112,10 +112,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 d164f530c8..a147a21c4f 100644 --- a/contrib/dlz/modules/filesystem/dlz_filesystem_dynamic.c +++ b/contrib/dlz/modules/filesystem/dlz_filesystem_dynamic.c @@ -105,10 +105,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;