Package: snoopy
Version: 2.4.6-6
Severity: minor
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu focal ubuntu-patch

Hi Marco,

In Ubuntu, the latest version of snoopy was failing to build on ppc64el
because Ubuntu builds ppc64el with -O3 by default, and the added
optimization causes a failure because gcc detects a possible truncation when
using strncpy():

[...]
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../.. -Wdate-time 
-D_FORTIFY_SOURCE=2 -Wall -Werror -Wextra -Wno-unused-parameter -std=c99 
-pedantic -I../../.. -g -O3 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. 
-fstack-protector-strong -Wformat -Werror=format-security -c ini.c  -fPIC -DPIC 
-o .libs/ini.o
In file included from /usr/include/string.h:494,
                 from ini.c:16:
In function ‘strncpy’,
    inlined from ‘strncpy0’ at ini.c:73:5,
    inlined from ‘ini_parse_stream’ at ini.c:202:17:
/usr/include/powerpc64le-linux-gnu/bits/string_fortified.h:106:10: error: 
‘__builtin_strncpy’ output may be truncated copying 49 bytes from a string of 
length 199 [-Werror=stringop-truncation]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[5]: *** [Makefile:462: ini.lo] Error 1
[...]

 (https://launchpad.net/ubuntu/+source/snoopy/2.4.6-6/+build/18085537)

This is an entirely safe use of strncpy in context, so I think this error
should just be overridden instead of giving the compiler its satisfaction.

The attached patch lets snoopy build on Ubuntu/ppc64el.  Would you consider
applying this in Debian, for improved compatibility with -O3 builds?

Cheers,
-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                   https://www.debian.org/
slanga...@ubuntu.com                                     vor...@debian.org
diff -Nru snoopy-2.4.6/debian/rules snoopy-2.4.6/debian/rules
--- snoopy-2.4.6/debian/rules   2019-11-08 15:23:51.000000000 -0800
+++ snoopy-2.4.6/debian/rules   2020-03-04 05:28:41.000000000 -0800
@@ -3,6 +3,7 @@
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
 
+export DEB_CFLAGS_MAINT_APPEND = -Wno-error=stringop-truncation
 %:
        dh $@
 

Reply via email to