summaryrefslogtreecommitdiffstats
path: root/plugins/check_smtp.c
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@mit.edu>2012-06-29 04:57:48 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2012-06-29 11:39:11 (GMT)
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 77ac5ce..6b3f9dd 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -156,15 +156,15 @@ main (int argc, char **argv)
156 } 156 }
157 } 157 }
158 if(use_ehlo) 158 if(use_ehlo)
159 asprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n"); 159 xasprintf (&helocmd, "%s%s%s", SMTP_EHLO, localhostname, "\r\n");
160 else 160 else
161 asprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n"); 161 xasprintf (&helocmd, "%s%s%s", SMTP_HELO, localhostname, "\r\n");
162 162
163 if (verbose) 163 if (verbose)
164 printf("HELOCMD: %s", helocmd); 164 printf("HELOCMD: %s", helocmd);
165 165
166 /* initialize the MAIL command with optional FROM command */ 166 /* initialize the MAIL command with optional FROM command */
167 asprintf (&cmd_str, "%sFROM:<%s>%s", mail_command, from_arg, "\r\n"); 167 xasprintf (&cmd_str, "%sFROM:<%s>%s", mail_command, from_arg, "\r\n");
168 168
169 if (verbose && smtp_use_dummycmd) 169 if (verbose && smtp_use_dummycmd)
170 printf ("FROM CMD: %s", cmd_str); 170 printf ("FROM CMD: %s", cmd_str);
@@ -299,7 +299,7 @@ main (int argc, char **argv)
299 } 299 }
300 300
301 while (n < ncommands) { 301 while (n < ncommands) {
302 asprintf (&cmd_str, "%s%s", commands[n], "\r\n"); 302 xasprintf (&cmd_str, "%s%s", commands[n], "\r\n");
303 my_send(cmd_str, strlen(cmd_str)); 303 my_send(cmd_str, strlen(cmd_str));
304 if (recvlines(buffer, MAX_INPUT_BUFFER) >= 1 && verbose) 304 if (recvlines(buffer, MAX_INPUT_BUFFER) >= 1 && verbose)
305 printf("%s", buffer); 305 printf("%s", buffer);
@@ -336,12 +336,12 @@ main (int argc, char **argv)
336 do { 336 do {
337 if (authuser == NULL) { 337 if (authuser == NULL) {
338 result = STATE_CRITICAL; 338 result = STATE_CRITICAL;
339 asprintf(&error_msg, _("no authuser specified, ")); 339 xasprintf(&error_msg, _("no authuser specified, "));
340 break; 340 break;
341 } 341 }
342 if (authpass == NULL) { 342 if (authpass == NULL) {
343 result = STATE_CRITICAL; 343 result = STATE_CRITICAL;
344 asprintf(&error_msg, _("no authpass specified, ")); 344 xasprintf(&error_msg, _("no authpass specified, "));
345 break; 345 break;
346 } 346 }
347 347
@@ -351,7 +351,7 @@ main (int argc, char **argv)
351 printf (_("sent %s\n"), "AUTH LOGIN"); 351 printf (_("sent %s\n"), "AUTH LOGIN");
352 352
353 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) { 353 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
354 asprintf(&error_msg, _("recv() failed after AUTH LOGIN, ")); 354 xasprintf(&error_msg, _("recv() failed after AUTH LOGIN, "));
355 result = STATE_WARNING; 355 result = STATE_WARNING;
356 break; 356 break;
357 } 357 }
@@ -360,7 +360,7 @@ main (int argc, char **argv)
360 360
361 if (strncmp (buffer, "334", 3) != 0) { 361 if (strncmp (buffer, "334", 3) != 0) {
362 result = STATE_CRITICAL; 362 result = STATE_CRITICAL;
363 asprintf(&error_msg, _("invalid response received after AUTH LOGIN, ")); 363 xasprintf(&error_msg, _("invalid response received after AUTH LOGIN, "));
364 break; 364 break;
365 } 365 }
366 366
@@ -374,7 +374,7 @@ main (int argc, char **argv)
374 374
375 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) { 375 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
376 result = STATE_CRITICAL; 376 result = STATE_CRITICAL;
377 asprintf(&error_msg, _("recv() failed after sending authuser, ")); 377 xasprintf(&error_msg, _("recv() failed after sending authuser, "));
378 break; 378 break;
379 } 379 }
380 if (verbose) { 380 if (verbose) {
@@ -382,7 +382,7 @@ main (int argc, char **argv)
382 } 382 }
383 if (strncmp (buffer, "334", 3) != 0) { 383 if (strncmp (buffer, "334", 3) != 0) {
384 result = STATE_CRITICAL; 384 result = STATE_CRITICAL;
385 asprintf(&error_msg, _("invalid response received after authuser, ")); 385 xasprintf(&error_msg, _("invalid response received after authuser, "));
386 break; 386 break;
387 } 387 }
388 /* encode authpass with base64 */ 388 /* encode authpass with base64 */
@@ -395,7 +395,7 @@ main (int argc, char **argv)
395 } 395 }
396 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) { 396 if ((ret = recvlines(buffer, MAX_INPUT_BUFFER)) <= 0) {
397 result = STATE_CRITICAL; 397 result = STATE_CRITICAL;
398 asprintf(&error_msg, _("recv() failed after sending authpass, ")); 398 xasprintf(&error_msg, _("recv() failed after sending authpass, "));
399 break; 399 break;
400 } 400 }
401 if (verbose) { 401 if (verbose) {
@@ -403,14 +403,14 @@ main (int argc, char **argv)
403 } 403 }
404 if (strncmp (buffer, "235", 3) != 0) { 404 if (strncmp (buffer, "235", 3) != 0) {
405 result = STATE_CRITICAL; 405 result = STATE_CRITICAL;
406 asprintf(&error_msg, _("invalid response received after authpass, ")); 406 xasprintf(&error_msg, _("invalid response received after authpass, "));
407 break; 407 break;
408 } 408 }
409 break; 409 break;
410 } while (0); 410 } while (0);
411 } else { 411 } else {
412 result = STATE_CRITICAL; 412 result = STATE_CRITICAL;
413 asprintf(&error_msg, _("only authtype LOGIN is supported, ")); 413 xasprintf(&error_msg, _("only authtype LOGIN is supported, "));
414 } 414 }
415 } 415 }
416 416
@@ -654,7 +654,7 @@ process_arguments (int argc, char **argv)
654 usage2 (_("Invalid hostname/address"), argv[c]); 654 usage2 (_("Invalid hostname/address"), argv[c]);
655 } 655 }
656 else { 656 else {
657 asprintf (&server_address, "127.0.0.1"); 657 xasprintf (&server_address, "127.0.0.1");
658 } 658 }
659 } 659 }
660 660
@@ -787,7 +787,7 @@ void
787print_help (void) 787print_help (void)
788{ 788{
789 char *myport; 789 char *myport;
790 asprintf (&myport, "%d", SMTP_PORT); 790 xasprintf (&myport, "%d", SMTP_PORT);
791 791
792 print_revision (progname, NP_VERSION); 792 print_revision (progname, NP_VERSION);
793 793