diff options
| author | Matthias Eble <psychotrahe@users.sourceforge.net> | 2007-07-14 19:36:48 +0000 |
|---|---|---|
| committer | Matthias Eble <psychotrahe@users.sourceforge.net> | 2007-07-14 19:36:48 +0000 |
| commit | c134205981203c7a6908f5ae1e3ca297bac83876 (patch) | |
| tree | 8f0ac3551738603626254093f781b073b357ca4a | |
| parent | 06372d2d910f714af5390d348a361b883a644897 (diff) | |
| download | monitoring-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
| -rw-r--r-- | THANKS.in | 1 | ||||
| -rw-r--r-- | plugins/check_smtp.c | 12 |
2 files changed, 9 insertions, 4 deletions
| @@ -221,3 +221,4 @@ Emil Michles | |||
| 221 | Ask Bjoern Hansen | 221 | Ask Bjoern Hansen |
| 222 | Daniel Bimschas | 222 | Daniel Bimschas |
| 223 | Aurelien Bompard | 223 | Aurelien Bompard |
| 224 | Christoph Schell | ||
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) | |||
| 582 | break; | 582 | break; |
| 583 | case 'C': /* commands */ | 583 | case 'C': /* commands */ |
| 584 | if (ncommands >= command_size) { | 584 | if (ncommands >= command_size) { |
| 585 | commands = realloc (commands, command_size+8); | 585 | command_size+=8; |
| 586 | commands = realloc (commands, sizeof(char *) * command_size); | ||
| 586 | if (commands == NULL) | 587 | if (commands == NULL) |
| 587 | die (STATE_UNKNOWN, | 588 | die (STATE_UNKNOWN, |
| 588 | _("Could not realloc() units [%d]\n"), ncommands); | 589 | _("Could not realloc() units [%d]\n"), ncommands); |
| 589 | } | 590 | } |
| 590 | commands[ncommands] = optarg; | 591 | commands[ncommands] = (char *) malloc (sizeof(char) * 255); |
| 592 | strncpy (commands[ncommands], optarg, 255); | ||
| 591 | ncommands++; | 593 | ncommands++; |
| 592 | break; | 594 | break; |
| 593 | case 'R': /* server responses */ | 595 | case 'R': /* server responses */ |
| 594 | if (nresponses >= response_size) { | 596 | if (nresponses >= response_size) { |
| 595 | responses = realloc (responses, response_size+8); | 597 | response_size += 8; |
| 598 | responses = realloc (responses, sizeof(char *) * response_size); | ||
| 596 | if (responses == NULL) | 599 | if (responses == NULL) |
| 597 | die (STATE_UNKNOWN, | 600 | die (STATE_UNKNOWN, |
| 598 | _("Could not realloc() units [%d]\n"), nresponses); | 601 | _("Could not realloc() units [%d]\n"), nresponses); |
| 599 | } | 602 | } |
| 600 | responses[nresponses] = optarg; | 603 | responses[nresponses] = (char *) malloc (sizeof(char) * 255); |
| 604 | strncpy (responses[nresponses], optarg, 255); | ||
| 601 | nresponses++; | 605 | nresponses++; |
| 602 | break; | 606 | break; |
| 603 | case 'c': /* critical time threshold */ | 607 | case 'c': /* critical time threshold */ |
