summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a1dd93a)
raw | patch | inline | side by side (parent: a1dd93a)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 4 Jun 2008 13:32:40 +0000 (15:32 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 4 Jun 2008 13:32:40 +0000 (15:32 +0200) |
Some other buffer handling has been improved, too.
src/notify_email.c | patch | blob | history |
diff --git a/src/notify_email.c b/src/notify_email.c
index f6c628e179612a97753bd2a692ad52abb5b0a21d..3d35f870f7c9d724b36e16f38855fe8578b2c45a 100644 (file)
--- a/src/notify_email.c
+++ b/src/notify_email.c
{
char log_str[MAXSTRING];
- strncpy(log_str, buf, buflen);
+ sstrncpy (log_str, buf, sizeof (log_str));
if (buflen > 2)
log_str[buflen - 2] = 0; /* replace \n with \0 */
smtp_set_monitorcb (session, monitor_cb, NULL, 1);
smtp_set_hostname (session, hostname_g);
- sprintf(server, "%s:%i", smtp_host == NULL ? DEFAULT_SMTP_HOST : smtp_host, smtp_port);
+ ssnprintf(server, sizeof (server), "%s:%i",
+ (smtp_host == NULL) ? DEFAULT_SMTP_HOST : smtp_host,
+ smtp_port);
smtp_set_server (session, server);
if (smtp_user && smtp_password) {
struct tm timestamp_tm;
char timestamp_str[64];
- char severity[MAXSTRING];
+ char severity[32];
char subject[MAXSTRING];
char buf[4096] = "";
int buf_len = sizeof (buf);
int i;
- sprintf (severity, "%s",
+ ssnprintf (severity, sizeof (severity), "%s",
(n->severity == NOTIF_FAILURE) ? "FAILURE"
: ((n->severity == NOTIF_WARNING) ? "WARNING"
: ((n->severity == NOTIF_OKAY) ? "OKAY" : "UNKNOWN")));
- sprintf (subject, smtp_subject == NULL ? DEFAULT_SMTP_SUBJECT : smtp_subject, severity, n->host);
+ ssnprintf (subject, sizeof (subject),
+ (smtp_subject == NULL) ? DEFAULT_SMTP_SUBJECT : smtp_subject,
+ severity, n->host);
localtime_r (&n->time, ×tamp_tm);
strftime (timestamp_str, sizeof (timestamp_str), "%Y-%m-%d %H:%M:%S", ×tamp_tm);
timestamp_str[sizeof (timestamp_str) - 1] = '\0';
/* Let's make RFC822 message text with \r\n EOLs */
- snprintf (buf, buf_len,
+ ssnprintf (buf, buf_len,
"MIME-Version: 1.0\r\n"
"Content-Type: text/plain;\r\n"
"Content-Transfer-Encoding: 8bit\r\n"