[Patch] - iv - Wformat-security

Suggestions for improvements to the NEURON Forum.
Post Reply
asinha2
Posts: 4
Joined: Thu Oct 09, 2014 10:46 am

[Patch] - iv - Wformat-security

Post by asinha2 »

Hello,

Quite a few Linux distributions (Fedora for example) are enabling the

Code: Select all

-Wformat-security
flag when compiling with GCC. IV fails to build with this flag. It's quite a simple fix. Patch below:

Code: Select all

diff -ur ../iv-18.orig/src/lib/IV-2_6/matcheditor.cpp ./src/lib/IV-2_6/matcheditor.cpp
--- ../iv-18.orig/src/lib/IV-2_6/matcheditor.cpp	2014-01-08 19:10:44.895487120 +1100
+++ ./src/lib/IV-2_6/matcheditor.cpp	2014-01-08 19:11:05.949315579 +1100
@@ -82,7 +82,7 @@
         strncpy(buf, text->Text(), length);
         while (length > 0) {
             buf[length] = '\0';
-            if (sscanf(buf, pattern) == EOF) {
+            if (sscanf(buf, "%s", pattern) == EOF) {
                 break;
             }
             --length;
More information on -Wformat-security can be found on the wiki page here.


There are also quite a few errors related to -Wnarrowing but I haven't a patch yet.
System details:

Code: Select all

[asinha@CS-1E114-2  iv]$ hg summary 
parent: 23:91e22c4a0a0c tip
 mingw+python+interviews works.
branch: default
commit: 2 modified, 591 unknown
update: (current)

[asinha@CS-1E114-2  iv]$ gcc --version
gcc (GCC) 6.1.1 20160621 (Red Hat 6.1.1-3)
asinha@CS-1E114-2  iv]$ cat /etc/os-release 
NAME=Fedora
VERSION="24 (Server Edition)"
...
Post Reply