diff --git a/centrallix-lib/src/cxsec.c b/centrallix-lib/src/cxsec.c index e07980d6d..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,23 +124,29 @@ 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 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 @@ -147,7 +154,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 +162,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' is not a valid symbol!\n", (int)original_n, original_symbol); + return -1; + }