From a96f786a6fdd0d2935fae03c087145efc42a088f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Sj=C3=B6lund?= Date: Mon, 25 Mar 2024 07:37:21 +0100 Subject: [PATCH] mountcomposefs: Handle empty basedir option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fail with an error message if any of the basedir option paths is an empty string. Signed-off-by: Erik Sjölund --- tools/mountcomposefs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/mountcomposefs.c b/tools/mountcomposefs.c index 29894cb..1e01b4f 100644 --- a/tools/mountcomposefs.c +++ b/tools/mountcomposefs.c @@ -216,10 +216,12 @@ int main(int argc, char **argv) if (options.objdirs == NULL) errx(EXIT_FAILURE, "Out of memory\n"); - for (i = 0, str = (char *)opt_basedir;; i++, str = NULL) { + for (i = 0, str = (char *)opt_basedir; i < options.n_objdirs; + i++, str = NULL) { token = strtok_r(str, ":", &saveptr); if (token == NULL) - break; + errx(EXIT_FAILURE, + "Value for basedir option has incorrect format\n"); options.objdirs[i] = token; } }