From 9bef26018f26a2819dcc1c5446c0afa79e91bda9 Mon Sep 17 00:00:00 2001 From: Lightning11wins Date: Tue, 3 Mar 2026 17:12:30 -0700 Subject: [PATCH 1/4] Add error message to cxsecVerifySymbol_n() --- centrallix-lib/src/cxsec.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/centrallix-lib/src/cxsec.c b/centrallix-lib/src/cxsec.c index e07980d6d..45890fb89 100644 --- a/centrallix-lib/src/cxsec.c +++ b/centrallix-lib/src/cxsec.c @@ -147,7 +147,7 @@ cxsecVerifySymbol_n(const char* sym, size_t n) ** significant security risks in the event of a locale mismatch!! **/ if (n <= 0 || (*sym != '_' && (*sym < 'A' || *sym > 'Z') && (*sym < 'a' || *sym > 'z'))) - return -1; + goto err; n--; /** Next chars may be 1) end of string, 2) digits, 3) alpha, or 4) underscore **/ @@ -155,11 +155,14 @@ cxsecVerifySymbol_n(const char* sym, size_t n) while(n) { if (*sym != '_' && (*sym < 'A' || *sym > 'Z') && (*sym < 'a' || *sym > 'z') && (*sym < '0' || *sym > '9')) - return -1; + goto err; sym++; n--; } - return 0; - } + return 0; + err: + fprintf(stderr, "WARNING: '%s' (of length %lu) is not a valid symbol!\n", sym, n); + return -1; + } From 1474fef54020923a1d27d8273632b47a23708ae4 Mon Sep 17 00:00:00 2001 From: Lightning11wins Date: Tue, 3 Mar 2026 17:52:29 -0700 Subject: [PATCH 2/4] Fix a bug in the error message logic. --- centrallix-lib/src/cxsec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/centrallix-lib/src/cxsec.c b/centrallix-lib/src/cxsec.c index 45890fb89..b3137192d 100644 --- a/centrallix-lib/src/cxsec.c +++ b/centrallix-lib/src/cxsec.c @@ -140,6 +140,7 @@ cxsecVerifySymbol(const char* sym) int cxsecVerifySymbol_n(const char* sym, size_t n) { + const char* original_symbol = sym; /** First char must be alpha or underscore, and must exist (len >= 1). ** We don't use isalpha() et al here because symbols need to conform to @@ -163,6 +164,6 @@ cxsecVerifySymbol_n(const char* sym, size_t n) return 0; err: - fprintf(stderr, "WARNING: '%s' (of length %lu) is not a valid symbol!\n", sym, n); + fprintf(stderr, "WARNING: '%s' is not a valid symbol!\n", original_symbol); return -1; } From c349ba3b5776c889dfd9993541440e21be375209 Mon Sep 17 00:00:00 2001 From: Lightning11wins Date: Tue, 3 Mar 2026 17:58:25 -0700 Subject: [PATCH 3/4] Fix a bug in the error message logic. --- centrallix-lib/src/cxsec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/centrallix-lib/src/cxsec.c b/centrallix-lib/src/cxsec.c index b3137192d..81098d110 100644 --- a/centrallix-lib/src/cxsec.c +++ b/centrallix-lib/src/cxsec.c @@ -141,6 +141,7 @@ int cxsecVerifySymbol_n(const char* sym, size_t n) { const char* original_symbol = sym; + const size_t original_n = n; /** First char must be alpha or underscore, and must exist (len >= 1). ** We don't use isalpha() et al here because symbols need to conform to @@ -164,6 +165,6 @@ cxsecVerifySymbol_n(const char* sym, size_t n) return 0; err: - fprintf(stderr, "WARNING: '%s' is not a valid symbol!\n", original_symbol); + fprintf(stderr, "WARNING: '%.*s' is not a valid symbol!\n", (int)original_n, original_symbol); return -1; } From c1fef337adc62dfaa5f3ae43a6a4ad2b1ee52359 Mon Sep 17 00:00:00 2001 From: Lightning11wins Date: Tue, 3 Mar 2026 17:59:59 -0700 Subject: [PATCH 4/4] Apply changes to cxsecVerifySymbol(). --- centrallix-lib/src/cxsec.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/centrallix-lib/src/cxsec.c b/centrallix-lib/src/cxsec.c index 81098d110..90c9ec02f 100644 --- a/centrallix-lib/src/cxsec.c +++ b/centrallix-lib/src/cxsec.c @@ -116,6 +116,7 @@ cxsecUpdateDS(unsigned long* start, unsigned long* end, char* file, int line) int cxsecVerifySymbol(const char* sym) { + const char* original_symbol = sym; /** First char must be alpha or underscore, and must exist (len >= 1). ** We don't use isalpha() et al here because symbols need to conform to @@ -123,18 +124,22 @@ cxsecVerifySymbol(const char* sym) ** significant security risks in the event of a locale mismatch!! **/ if (*sym != '_' && (*sym < 'A' || *sym > 'Z') && (*sym < 'a' || *sym > 'z')) - return -1; + goto err; /** Next chars may be 1) end of string, 2) digits, 3) alpha, or 4) underscore **/ sym++; while(*sym) { if (*sym != '_' && (*sym < 'A' || *sym > 'Z') && (*sym < 'a' || *sym > 'z') && (*sym < '0' || *sym > '9')) - return -1; + goto err; sym++; } - return 0; + return 0; + + err: + fprintf(stderr, "WARNING: '%s' is not a valid symbol!\n", original_symbol); + return -1; } int