diff --git a/centrallix-lib/src/cxsec.c b/centrallix-lib/src/cxsec.c index c5d27c541..930e42c31 100644 --- a/centrallix-lib/src/cxsec.c +++ b/centrallix-lib/src/cxsec.c @@ -124,6 +124,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 @@ -131,24 +132,30 @@ 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 @@ -156,7 +163,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 **/ @@ -164,12 +171,16 @@ 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; }