[balsa/wip/gtk4] send: Fix a compiler warning
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/wip/gtk4] send: Fix a compiler warning
- Date: Sun, 21 Apr 2019 02:00:16 +0000 (UTC)
commit 3c6d41299c5d86416f91f2ef414b84b733a315f5
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.
libbalsa/send.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/libbalsa/send.c b/libbalsa/send.c
index 0f8181277..8f081c277 100644
--- a/libbalsa/send.c
+++ b/libbalsa/send.c
@@ -1589,9 +1589,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]