Skip to content

Commit

Permalink
check_dummy: fix crash on empty output and support quotes for first a…
Browse files Browse the repository at this point in the history
…rgument
  • Loading branch information
sni committed Oct 17, 2023
1 parent b036d83 commit 0b4c7f8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
This file documents the revision history for mod_gearman.

next:
- check_dummy: fix crash if output is empty
- check_dummy: support putting return code in quotes

5.1.2 Thu Jun 29 11:02:35 CEST 2023
- neb: add internal check_dummy
- change pid file location to /run in packages
Expand Down
20 changes: 17 additions & 3 deletions neb_module_naemon/mod_gearman.c
Original file line number Diff line number Diff line change
Expand Up @@ -1976,20 +1976,34 @@ static int try_check_dummy(const char * command_line, host * hst, service * svc)
return(GM_ERROR);
}


char *arg1 = strtok( NULL, " " );
char *output = strtok( NULL, "");
if(arg1 == NULL)
arg1 = "";
// return code starts with double quote, take string until next double quote
if(arg1[0] == '"') {
arg1++;
arg1 = strtok( arg1, "\"" );
if(arg1 == NULL)
arg1 = "";
}
// return code starts with single quote, take string until next single quote
else if(arg1[0] == '\'') {
arg1++;
arg1 = strtok( arg1, "'" );
}

char *output = strtok( NULL, "");
if(output == NULL) {
if(output == NULL)
output = "";
}

// string starts with double quote, take string until next double quote
if(output[0] == '"') {
output++;
output = strtok( output, "\"" );
check_for_shell_chars = TRUE;
if(output == NULL)
output = "";
}
// string starts with single quote, take string until next single quote
else if(output[0] == '\'') {
Expand Down

0 comments on commit 0b4c7f8

Please sign in to comment.