summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2004-01-21 12:49:12 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2004-01-21 12:49:12 +0000
commitc760a04e1afd924c063b9b37b1e9c451dc908c64 (patch)
treea9dcd3178cb421b59a28bab682144e6d734cd83f
parent37fc36aba8d107facbd8e02df1f1138ed14efa10 (diff)
downloadmonitoring-plugins-c760a04e1afd924c063b9b37b1e9c451dc908c64.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/branches/release-1.3.0@796 f882894a-f735-0410-b71e-b25c423dba1c
-rw-r--r--plugins/check_tcp.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c
index c6acca76..e4c2440c 100644
--- a/plugins/check_tcp.c
+++ b/plugins/check_tcp.c
@@ -187,9 +187,9 @@ main (int argc, char **argv)
187 asprintf (&SERVICE, "NNTP"); 187 asprintf (&SERVICE, "NNTP");
188 SEND = NULL; 188 SEND = NULL;
189 EXPECT = NULL; 189 EXPECT = NULL;
190 server_expect = realloc (server_expect, ++server_expect_count); 190 server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count));
191 asprintf (&server_expect[server_expect_count - 1], "200"); 191 asprintf (&server_expect[server_expect_count - 1], "200");
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], "201"); 193 asprintf (&server_expect[server_expect_count - 1], "201");
194 asprintf (&QUIT, "QUIT\r\n"); 194 asprintf (&QUIT, "QUIT\r\n");
195 PROTOCOL = TCP_PROTOCOL; 195 PROTOCOL = TCP_PROTOCOL;
@@ -209,7 +209,7 @@ main (int argc, char **argv)
209 209
210 /* use default expect if none listed in process_arguments() */ 210 /* use default expect if none listed in process_arguments() */
211 if (EXPECT && server_expect_count == 0) { 211 if (EXPECT && server_expect_count == 0) {
212 server_expect = malloc (++server_expect_count); 212 server_expect = malloc (sizeof (char *) * (++server_expect_count));
213 server_expect[server_expect_count - 1] = EXPECT; 213 server_expect[server_expect_count - 1] = EXPECT;
214 } 214 }
215 215
@@ -447,9 +447,9 @@ process_arguments (int argc, char **argv)
447 case 'e': /* expect string (may be repeated) */ 447 case 'e': /* expect string (may be repeated) */
448 EXPECT = NULL; 448 EXPECT = NULL;
449 if (server_expect_count == 0) 449 if (server_expect_count == 0)
450 server_expect = malloc (++server_expect_count); 450 server_expect = malloc (sizeof (char *) * (++server_expect_count));
451 else 451 else
452 server_expect = realloc (server_expect, ++server_expect_count); 452 server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count));
453 server_expect[server_expect_count - 1] = optarg; 453 server_expect[server_expect_count - 1] = optarg;
454 break; 454 break;
455 case 'm': 455 case 'm':