aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_smtp.c
diff options
context:
space:
mode:
authorGravatar Anders Kaseorg <andersk@mit.edu> 2012-06-29 00:57:48 -0400
committerGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2012-06-29 13:39:11 +0200
commit028d50d6f99e647a325a0a68303016382c4bbdc9 (patch)
tree1d9a14635602169d137409becfa108cd6bdb371c /plugins/check_smtp.c
parent9976876584e5a1df6e1c9315212c3d274df7a12e (diff)
downloadmonitoring-plugins-028d50d6f99e647a325a0a68303016382c4bbdc9.tar.gz
Die when asprintf fails
Fixes many instances of warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result] Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Diffstat (limited to 'plugins/check_smtp.c')
-rw-r--r--plugins/check_smtp.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 77ac5ced..6b3f9dd4 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -156,15 +156,15 @@ main (int argc, char **argv)
}
}
if(use_ehlo)
- asprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
+ xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
else
- asprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
+ xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
if (verbose)
printf("HELOCMD: %s", helocmd);
/* initialize the MAIL command with optional FROM command */
- asprintf (&cmd_str, "%sFROM:<%s>%s", mail_command, from_arg, "\r\n");
+ xasprintf (&cmd_str, "%sFROM:<%s>%s", mail_command, from_arg, "\r\n");
if (verbose && smtp_use_dummycmd)
printf ("FROM CMD: %s", cmd_str);
@@ -299,7 +299,7 @@ main (int argc, char **argv)
}
while (n < ncommands) {
- asprintf (&cmd_str, "%s%s", commands[n], "\r\n");
+ xasprintf (&cmd_str, "%s%s", commands[n], "\r\n");
my_send(cmd_str, strlen(cmd_str));
if (recvlines(buffer, MAX_INPUT_BUFFER) >= 1 && verbose)
printf("%s", buffer);
@@ -336,12 +336,12 @@ main (int argc, char **argv)
do {
if (authuser == NULL) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("no authuser specified, "));
+ xasprintf(&error_msg, _("no authuser specified, "));
break;
}
if (authpass == NULL) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("no authpass specified, "));
+ xasprintf(&error_msg, _("no authpass specified, "));
break;
}
@@ -351,7 +351,7 @@ main (int argc, char **argv)
printf (_("sent %s\n"), "AUTH LOGIN");
if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
- asprintf(&error_msg, _("recv() failed after AUTH LOGIN, "));
+ xasprintf(&error_msg, _("recv() failed after AUTH LOGIN, "));
result = STATE_WARNING;
break;
}
@@ -360,7 +360,7 @@ main (int argc, char **argv)
if (strncmp (buffer, "334", 3) != 0) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("invalid response received after AUTH LOGIN, "));
+ xasprintf(&error_msg, _("invalid response received after AUTH LOGIN, "));
break;
}
@@ -374,7 +374,7 @@ main (int argc, char **argv)
if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("recv() failed after sending authuser, "));
+ xasprintf(&error_msg, _("recv() failed after sending authuser, "));
break;
}
if (verbose) {
@@ -382,7 +382,7 @@ main (int argc, char **argv)
}
if (strncmp (buffer, "334", 3) != 0) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("invalid response received after authuser, "));
+ xasprintf(&error_msg, _("invalid response received after authuser, "));
break;
}
/* encode authpass with base64 */
@@ -395,7 +395,7 @@ main (int argc, char **argv)
}
if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("recv() failed after sending authpass, "));
+ xasprintf(&error_msg, _("recv() failed after sending authpass, "));
break;
}
if (verbose) {
@@ -403,14 +403,14 @@ main (int argc, char **argv)
}
if (strncmp (buffer, "235", 3) != 0) {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("invalid response received after authpass, "));
+ xasprintf(&error_msg, _("invalid response received after authpass, "));
break;
}
break;
} while (0);
} else {
result = STATE_CRITICAL;
- asprintf(&error_msg, _("only authtype LOGIN is supported, "));
+ xasprintf(&error_msg, _("only authtype LOGIN is supported, "));
}
}
@@ -654,7 +654,7 @@ process_arguments (int argc, char **argv)
usage2 (_("Invalid hostname/address"), argv[c]);
}
else {
- asprintf (&server_address, "127.0.0.1");
+ xasprintf (&server_address, "127.0.0.1");
}
}
@@ -787,7 +787,7 @@ void
print_help (void)
{
char *myport;
- asprintf (&myport, "%d", SMTP_PORT);
+ xasprintf (&myport, "%d", SMTP_PORT);
print_revision (progname, NP_VERSION);