[balsa/wip/gtk4: 233/351] Silence a gcc gripe about strncpy



commit bee684eb32efea0a17b620b8a348becae8d7f9cc
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 565d675..4fa62fe 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 57f3838..b5efb46 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]