diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2004-01-21 12:49:12 (GMT) |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2004-01-21 12:49:12 (GMT) |
commit | 9b5b447fcae3a1e3dcd5c00734eed34b0dc91857 (patch) | |
tree | 90b9b352f8a7120886642513932a2f6a72ece35a /plugins/check_tcp.c | |
parent | f152e45257451d5b898373db6dfad6ee123199b1 (diff) | |
download | monitoring-plugins-9b5b447fcae3a1e3dcd5c00734eed34b0dc91857.tar.gz |
=fix segfault on malloc of server_expect for multibyte chars (David Croft)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@796 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_tcp.c')
-rw-r--r-- | plugins/check_tcp.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index c105c6a..7bd48d1 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c | |||
@@ -189,9 +189,9 @@ main (int argc, char **argv) | |||
189 | SERVICE = strdup ("NNTP"); | 189 | SERVICE = strdup ("NNTP"); |
190 | SEND = NULL; | 190 | SEND = NULL; |
191 | EXPECT = NULL; | 191 | EXPECT = NULL; |
192 | server_expect = realloc (server_expect, ++server_expect_count); | 192 | server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count)); |
193 | asprintf (&server_expect[server_expect_count - 1], "200"); | 193 | asprintf (&server_expect[server_expect_count - 1], "200"); |
194 | server_expect = realloc (server_expect, ++server_expect_count); | 194 | server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count)); |
195 | asprintf (&server_expect[server_expect_count - 1], "201"); | 195 | asprintf (&server_expect[server_expect_count - 1], "201"); |
196 | asprintf (&QUIT, "QUIT\r\n"); | 196 | asprintf (&QUIT, "QUIT\r\n"); |
197 | PROTOCOL = TCP_PROTOCOL; | 197 | PROTOCOL = TCP_PROTOCOL; |
@@ -212,7 +212,7 @@ main (int argc, char **argv) | |||
212 | 212 | ||
213 | /* use default expect if none listed in process_arguments() */ | 213 | /* use default expect if none listed in process_arguments() */ |
214 | if (EXPECT && server_expect_count == 0) { | 214 | if (EXPECT && server_expect_count == 0) { |
215 | server_expect = malloc (++server_expect_count); | 215 | server_expect = malloc (sizeof (char *) * (++server_expect_count)); |
216 | server_expect[server_expect_count - 1] = EXPECT; | 216 | server_expect[server_expect_count - 1] = EXPECT; |
217 | } | 217 | } |
218 | 218 | ||
@@ -470,9 +470,9 @@ process_arguments (int argc, char **argv) | |||
470 | case 'e': /* expect string (may be repeated) */ | 470 | case 'e': /* expect string (may be repeated) */ |
471 | EXPECT = NULL; | 471 | EXPECT = NULL; |
472 | if (server_expect_count == 0) | 472 | if (server_expect_count == 0) |
473 | server_expect = malloc (++server_expect_count); | 473 | server_expect = malloc (sizeof (char *) * (++server_expect_count)); |
474 | else | 474 | else |
475 | server_expect = realloc (server_expect, ++server_expect_count); | 475 | server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count)); |
476 | server_expect[server_expect_count - 1] = optarg; | 476 | server_expect[server_expect_count - 1] = optarg; |
477 | break; | 477 | break; |
478 | case 'm': | 478 | case 'm': |