summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-06-23 19:08:00 +0200
committerCarl Hetherington <cth@carlh.net>2024-06-23 19:51:28 +0200
commit788fb4dd037f0459a797e7310d0f7a981d8e6cfc (patch)
tree38e42386ac0c6289c21101bb50d5aae366d13e4c
parent117f6bd199479fdaeff665acbea109e967500308 (diff)
Remove sprintf() use to quell warning from macOS.
-rw-r--r--src/lib/email.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lib/email.cc b/src/lib/email.cc
index bd17bdf5b..6b4012c22 100644
--- a/src/lib/email.cc
+++ b/src/lib/email.cc
@@ -119,7 +119,8 @@ Email::send(string server, int port, EmailProtocol protocol, string user, string
auto const utc_now = boost::posix_time::second_clock::universal_time ();
auto const local_now = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local (utc_now);
auto offset = local_now - utc_now;
- sprintf (date_buffer + strlen(date_buffer), "%s%02d%02d", (offset.hours() >= 0 ? "+" : "-"), int(abs(offset.hours())), int(offset.minutes()));
+ auto end = date_buffer + strlen(date_buffer);
+ snprintf(end, sizeof(date_buffer) - (end - date_buffer), "%s%02d%02d", (offset.hours() >= 0 ? "+" : "-"), int(abs(offset.hours())), int(offset.minutes()));
_email = "Date: " + string(date_buffer) + "\r\n"
"To: " + address_list (_to) + "\r\n"