From c760a04e1afd924c063b9b37b1e9c451dc908c64 Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Wed, 21 Jan 2004 12:49:12 +0000 Subject: =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 --- plugins/check_tcp.c | 10 +++++----- 1 file 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) asprintf (&SERVICE, "NNTP"); SEND = NULL; EXPECT = NULL; - server_expect = realloc (server_expect, ++server_expect_count); + server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count)); asprintf (&server_expect[server_expect_count - 1], "200"); - server_expect = realloc (server_expect, ++server_expect_count); + server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count)); asprintf (&server_expect[server_expect_count - 1], "201"); asprintf (&QUIT, "QUIT\r\n"); PROTOCOL = TCP_PROTOCOL; @@ -209,7 +209,7 @@ main (int argc, char **argv) /* use default expect if none listed in process_arguments() */ if (EXPECT && server_expect_count == 0) { - server_expect = malloc (++server_expect_count); + server_expect = malloc (sizeof (char *) * (++server_expect_count)); server_expect[server_expect_count - 1] = EXPECT; } @@ -447,9 +447,9 @@ process_arguments (int argc, char **argv) case 'e': /* expect string (may be repeated) */ EXPECT = NULL; if (server_expect_count == 0) - server_expect = malloc (++server_expect_count); + server_expect = malloc (sizeof (char *) * (++server_expect_count)); else - server_expect = realloc (server_expect, ++server_expect_count); + server_expect = realloc (server_expect, sizeof (char *) * (++server_expect_count)); server_expect[server_expect_count - 1] = optarg; break; case 'm': -- cgit v1.2.3-74-g34f1