[nagiosplug] check_smtp: Fix strcat overflows

"Nagios Plugin Development" <[email protected]> Fri, 29 Jun 2012 12:21:00 +0000
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
    Module: nagiosplug
    Branch: master
    Commit: 638b596992feabc7cb8a74a788b9426e4e2e95a3
    Author: Anders Kaseorg <[email protected]>
 Committer: Holger Weiss <[email protected]>
      Date: Fri Jun 29 00:28:46 2012 -0400
       URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=638b596

check_smtp: Fix strcat overflows

Signed-off-by: Anders Kaseorg <[email protected]>

---

 plugins/check_smtp.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 6b3f9dd..2a60cf0 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -366,8 +366,7 @@ main (int argc, char **argv)
 
 					/* encode authuser with base64 */
 					base64_encode_alloc (authuser, strlen(authuser), &abuf);
-					/* FIXME: abuf shouldn't have enough space to strcat a '\r\n' into it. */
-					strcat (abuf, "\r\n");
+					xasprintf(&abuf, "%s\r\n", abuf);
 					my_send(abuf, strlen(abuf));
 					if (verbose)
 						printf (_("sent %s\n"), abuf);
@@ -387,8 +386,7 @@ main (int argc, char **argv)
 					}
 					/* encode authpass with base64 */
 					base64_encode_alloc (authpass, strlen(authpass), &abuf);
-					/* FIXME: abuf shouldn't have enough space to strcat a '\r\n' into it. */
-					strcat (abuf, "\r\n");
+					xasprintf(&abuf, "%s\r\n", abuf);
 					my_send(abuf, strlen(abuf));
 					if (verbose) {
 						printf (_("sent %s\n"), abuf);


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/