From: Michal Rakowski Date: Thu, 18 Nov 2021 12:28:07 +0000 (+0100) Subject: move 'check_for_invalid_chars' helper to common code X-Git-Tag: Beta-15.0.0~761 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d9b6113ff276dae13a520c4e0ff6ea5189e9489;p=thirdparty%2Fbacula.git move 'check_for_invalid_chars' helper to common code --- diff --git a/bacula/src/lib/edit.c b/bacula/src/lib/edit.c index 5a19b305c..081125820 100644 --- a/bacula/src/lib/edit.c +++ b/bacula/src/lib/edit.c @@ -546,7 +546,56 @@ bool is_name_valid(const char *name, POOLMEM **msg, const char *accept) return true; } +/* Small helper method, so far used only by the PostgreSQL and MySQL plugins + * to check if name provided by the user can be used. + * Checks if given string does not contain suspicious characters, as well as + * informs the called if it's already double-quoted or not, to know if it needs + * some further processing. + * @ret false if no invalid character is found + * @ret true if some invalid character is found ('err' is filed with message in that case) + */ +bool check_for_invalid_chars(const char *str, POOLMEM **err, bool *quote_needed) +{ + *quote_needed = true; + int len = strlen(str); + for (int i=0; i