From 08d3caf30eefbc41f324e307ee8e62a319abfd0f Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 5 May 2025 16:13:33 +0200 Subject: [PATCH] MINOR: cfgparse: visually show the input line on empty args Now when an empty arg is found on a line, we emit the sanitized input line and the position of the first empty arg so as to help the user figure the cause (likely an empty environment variable). Co-authored-by: Valentine Krasnobaeva --- src/cfgparse.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cfgparse.c b/src/cfgparse.c index 2123dd4c5..3421a0997 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2066,11 +2066,17 @@ next_line: } for (check_arg = 0; check_arg < arg; check_arg++) { - if (*args[check_arg]) - continue; - ha_warning("parsing [%s:%d]: argument number %d is empty and marks the end of the argument list; all subsequent arguments will be ignored.\n", - file, linenum, check_arg + 1); - break; + if (!*args[check_arg]) { + /* if an empty arg was found, its pointer is in */ + size_t newpos; + + /* sanitize input line in-place */ + newpos = sanitize_for_printing(line, errptr - line, 80); + ha_warning("parsing [%s:%d]: argument number %d at position %d is empty and marks the end of the " + "argument list; all subsequent arguments will be ignored:\n %s\n %*s\n", + file, linenum, check_arg + 1, (int)(errptr - thisline + 1), line, (int)(newpos+1), "^"); + break; + } } /* everything's OK */ -- 2.39.5