mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-15 22:00:06 -04:00
check_snmp: improve string quoting in result
This commit is contained in:
parent
a7c6760cfe
commit
41d309d438
1 changed files with 16 additions and 1 deletions
|
|
@ -235,8 +235,23 @@ int main(int argc, char **argv) {
|
|||
if (verbose) {
|
||||
printf("Debug: Got a string\n");
|
||||
}
|
||||
|
||||
char *tmp = (char *)vars->val.string;
|
||||
xasprintf(&sc_oid_test.output, "%s - Value: %s", sc_oid_test.output, tmp);
|
||||
|
||||
if (strchr(tmp, '"') != NULL) {
|
||||
// got double quote in the string
|
||||
if (strchr(tmp, '\'') != NULL) {
|
||||
// got single quote in the string too
|
||||
// dont quote that at all to avoid even more confusion
|
||||
xasprintf(&sc_oid_test.output, "%s - Value: %s", sc_oid_test.output, tmp);
|
||||
} else {
|
||||
// quote with single quotes
|
||||
xasprintf(&sc_oid_test.output, "%s - Value: '%s'", sc_oid_test.output, tmp);
|
||||
}
|
||||
} else {
|
||||
// quote with double quotes
|
||||
xasprintf(&sc_oid_test.output, "%s - Value: \"%s\"", sc_oid_test.output, tmp);
|
||||
}
|
||||
|
||||
if (strlen(tmp) == 0) {
|
||||
sc_oid_test = mp_set_subcheck_state(sc_oid_test, config.nulloid_result);
|
||||
|
|
|
|||
Loading…
Reference in a new issue