[gnome-commander/ConvertWarningsToErrors] gnome-cmd-advrename-lexer.ll: fix for format-overflow



commit b96e896481e6154cbb8cd83c84f0b9297c5d1c92
Author: Mamoru TASAKA <mtasaka fedoraproject org>
Date:   Thu Apr 20 00:15:19 2017 +0900

    gnome-cmd-advrename-lexer.ll: fix for format-overflow
    
    gnome-cmd-advrename-lexer.cc:806:21: error: '%i' directive writing between 1 and 11 bytes into a region 
of size 7 [-Werror=format-overflow=]
    In file included from /usr/include/stdio.h:939:0,
                     from gnome-cmd-advrename-lexer.cc:19:
    /usr/include/bits/stdio2.h:34:43: note: '__builtin___sprintf_chk' output between 6 and 16 bytes into a 
destination of size 9
    
    This warning is from GCC 7
    Well, this warning may be confusing, however this says that at the line
    
    sprintf(p->counter.fmt,"%%0%ili",p->counter.prec);
    
    p->counter.prec has the size 9, while %i may take 11 bytes, so "%%0%ili" may take at most 16 bytes 
(including the terminating null character), so the buffer size may be insufficient.

 src/gnome-cmd-advrename-lexer.ll |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/gnome-cmd-advrename-lexer.ll b/src/gnome-cmd-advrename-lexer.ll
index 24733de..a91b93b 100644
--- a/src/gnome-cmd-advrename-lexer.ll
+++ b/src/gnome-cmd-advrename-lexer.ll
@@ -81,7 +81,7 @@ struct CHUNK
       int prec;
       int init_step;
       int init_prec;
-      char fmt[9];
+      char fmt[16];
     } counter;
 
     struct


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]