[balsa] Silence a gcc gripe about strncpy
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Silence a gcc gripe about strncpy
- Date: Mon, 19 Mar 2018 17:26:17 +0000 (UTC)
commit 6baa13b41858b656e5e3844cce6ec118bba958bc
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Mon Mar 19 13:19:47 2018 -0400
Silence a gcc gripe about strncpy
when the byte count equals the buffer size. Copy at most one fewer bytes,
so that gcc *knows* that we are going to nul-terminate the destination
string. This makes no operational difference, as the last byte would
be overwritten with the nul in the exceptional case when the limit
is reached.
* libbalsa/imap/imap-commands.c (imap_mbox_handle_fetch_body):
silence a gcc gripe about strncpy.
ChangeLog | 5 +++++
libbalsa/imap/imap-commands.c | 2 +-
2 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5603ea9..d5b7e70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-03-19 Peter Bloomfield <pbloomfield bellsouth net>
+
+ * libbalsa/imap/imap-commands.c (imap_mbox_handle_fetch_body):
+ silence a gcc gripe about strncpy.
+
2018-02-27 Pawel Salek <pawsa0 gmail com>
* src/main-window.c: update a date.
diff --git a/libbalsa/imap/imap-commands.c b/libbalsa/imap/imap-commands.c
index 6cfbc9e..5ad5f63 100644
--- a/libbalsa/imap/imap-commands.c
+++ b/libbalsa/imap/imap-commands.c
@@ -1445,7 +1445,7 @@ imap_mbox_handle_fetch_body(ImapMboxHandle* handle,
/* We have to strip last section part and replace it with HEADER */
unsigned sz;
char *last_dot = strrchr(section, '.');
- strncpy(prefix, section, sizeof(prefix));
+ strncpy(prefix, section, sizeof(prefix) - 1);
if(last_dot) {
sz = last_dot-section+1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]