[balsa/wip/gmime3: 190/197] Silence a gcc gripe about strncpy



commit 1f4144eea13c391014d2a3008e0f8d31d42dbf6b
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 acd2830..1de5552 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]