aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_smtp.c
diff options
context:
space:
mode:
authorGravatar Matthias Eble <psychotrahe@users.sourceforge.net> 2007-07-14 19:36:48 +0000
committerGravatar Matthias Eble <psychotrahe@users.sourceforge.net> 2007-07-14 19:36:48 +0000
commitc134205981203c7a6908f5ae1e3ca297bac83876 (patch)
tree8f0ac3551738603626254093f781b073b357ca4a /plugins/check_smtp.c
parent06372d2d910f714af5390d348a361b883a644897 (diff)
downloadmonitoring-plugins-c134205981203c7a6908f5ae1e3ca297bac83876.tar.gz
Fixed segfault in argument processing. Thanks to Christoph Schell (#1742066)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1757 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_smtp.c')
-rw-r--r--plugins/check_smtp.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 5001b502..a7a07838 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -582,22 +582,26 @@ process_arguments (int argc, char **argv)
break;
case 'C': /* commands */
if (ncommands >= command_size) {
- commands = realloc (commands, command_size+8);
+ command_size+=8;
+ commands = realloc (commands, sizeof(char *) * command_size);
if (commands == NULL)
die (STATE_UNKNOWN,
_("Could not realloc() units [%d]\n"), ncommands);
}
- commands[ncommands] = optarg;
+ commands[ncommands] = (char *) malloc (sizeof(char) * 255);
+ strncpy (commands[ncommands], optarg, 255);
ncommands++;
break;
case 'R': /* server responses */
if (nresponses >= response_size) {
- responses = realloc (responses, response_size+8);
+ response_size += 8;
+ responses = realloc (responses, sizeof(char *) * response_size);
if (responses == NULL)
die (STATE_UNKNOWN,
_("Could not realloc() units [%d]\n"), nresponses);
}
- responses[nresponses] = optarg;
+ responses[nresponses] = (char *) malloc (sizeof(char) * 255);
+ strncpy (responses[nresponses], optarg, 255);
nresponses++;
break;
case 'c': /* critical time threshold */