[balsa] send: Fix a compiler warning
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] send: Fix a compiler warning
- Date: Sun, 21 Apr 2019 01:48:56 +0000 (UTC)
commit 7b93e90c639267dd14aed2efc2428314f918e632
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sat Apr 20 21:46:20 2019 -0400
send: Fix a compiler warning
* libbalsa/send.c (libbalsa_set_message_id): strncpy() with n ==
sizeof(dest) generates:
"error: ‘__builtin_strncpy’ specified bound 16 equals
destination size [-Werror=stringop-truncation]"
We now specify one fewer bytes, and explicitly nullify the last
byte.
ChangeLog | 11 +++++++++++
libbalsa/send.c | 6 ++++--
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 653d59768..29dcf8ead 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2019-04-20 Peter Bloomfield <pbloomfield bellsouth net>
+
+ send: Fix a compiler warning
+
+ * libbalsa/send.c (libbalsa_set_message_id): strncpy() with n ==
+ sizeof(dest) generates:
+ "error: ‘__builtin_strncpy’ specified bound 16 equals
+ destination size [-Werror=stringop-truncation]"
+ We now specify one fewer bytes, and explicitly nullify the last
+ byte.
+
2019-04-18 Albrecht Dreß <albrecht dress arcor de>
Fix the build after commit e92ec3140a1c81dbf86d90d0155cb2e08f519db2
diff --git a/libbalsa/send.c b/libbalsa/send.c
index a68f1b079..e42a7c840 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -1602,9 +1602,11 @@ libbalsa_set_message_id(GMimeMessage *mime_message)
/* initialise some stuff on first-time use... */
rand = g_rand_new_with_seed((guint32) time(NULL));
strncpy(id_data.user_name, g_get_user_name(),
- sizeof(id_data.user_name));
+ sizeof(id_data.user_name) - 1);
+ id_data.user_name[sizeof(id_data.user_name) - 1] = '\0';
strncpy(id_data.host_name, g_get_host_name(),
- sizeof(id_data.host_name));
+ sizeof(id_data.host_name) - 1);
+ id_data.host_name[sizeof(id_data.host_name) - 1] = '\0';
}
/* get some randomness... */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]