Package: intelrdfpmath
Version: 2.0u2-8
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu mantic ubuntu-patch

Dear maintainers,

The intelrdfpmath package is failing to build on all architectures in Ubuntu
because some test cases are being built with -Werror, and this is currently
stricter on Ubuntu than on Debian:

[...]
make[2]: Entering directory '/<<PKGBUILDDIR>>/TESTS'
x86_64-linux-gnu-gcc -O0 -D__intptr_t_defined -DLINUX -Werror 
-DDECIMAL_CALL_BY_REFERENCE=0 -DDECIMAL_GLOBAL_ROUNDING=0 
-DDECIMAL_GLOBAL_EXCEPTION_FLAGS=0 -UBID_BIG_ENDIAN -UHPUX_OS    -o readtest 
readtest.c ../LIBRARY/libbidgcc000.a -lm 
readtest.c: In function ‘print_mismatch’:
readtest.c:1397:24: error: ‘ ’ directive writing 1 byte into a region of size 
between 0 and 1023 [-Werror=format-overflow=]
 1397 |   sprintf (line, "%s %s %s %s\n", func, op1, op2, op3);
      |                        ^
readtest.c:1397:3: note: ‘sprintf’ output 5 or more bytes (assuming 3074) into 
a destination of size 1024
 1397 |   sprintf (line, "%s %s %s %s\n", func, op1, op2, op3);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [makefile:126: readtest] Error 1
[...]

  (https://launchpad.net/ubuntu/+source/intelrdfpmath/2.0u2-8/+build/26010059)

While not currently a build failure in Debian, we can expect it to become
one with a future compiler update.

Unfortunately, using snprintf() to enforce bounds checking of the target
array doesn't avert this error, because format-truncation is also applied to
the buffer in snprintf().  But the attached patch lets the package build, by
both using snprintf() for more explict safety wrt buffer handling, and
turning off this particular error from gcc.

I've uploaded this to Ubuntu to let the package build there.

Thanks for considering,
-- 
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 intelrdfpmath-2.0u2/debian/patches/series 
intelrdfpmath-2.0u2/debian/patches/series
--- intelrdfpmath-2.0u2/debian/patches/series   2023-02-08 06:20:15.000000000 
-0800
+++ intelrdfpmath-2.0u2/debian/patches/series   2023-06-13 10:35:51.000000000 
-0700
@@ -3,3 +3,4 @@
 abs-declaration.patch
 wchar_t.patch
 mongo-inteldfp-s390x.patch
+snprintf-not-sprintf.patch
diff -Nru intelrdfpmath-2.0u2/debian/patches/snprintf-not-sprintf.patch 
intelrdfpmath-2.0u2/debian/patches/snprintf-not-sprintf.patch
--- intelrdfpmath-2.0u2/debian/patches/snprintf-not-sprintf.patch       
1969-12-31 16:00:00.000000000 -0800
+++ intelrdfpmath-2.0u2/debian/patches/snprintf-not-sprintf.patch       
2023-06-13 10:39:53.000000000 -0700
@@ -0,0 +1,38 @@
+Description: use snprintf not sprintf to make the compiler happy
+ With the gcc currently in Ubuntu, the package build fails because the
+ compiler can't tell whether this sprintf() will overflow the target.
+ Just use snprintf() to ensure that it can't.
+ .
+ But -Werror=format-truncation triggers *anyway* even on snprintf, so
+ disable this error as well.
+Author: Steve Langasek <steve.langa...@ubuntu.com>
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/2023683
+Last-Update: 2023-06-13
+Forwarded: no
+
+Index: intelrdfpmath-2.0u2/TESTS/readtest.c
+===================================================================
+--- intelrdfpmath-2.0u2.orig/TESTS/readtest.c
++++ intelrdfpmath-2.0u2/TESTS/readtest.c
+@@ -1394,7 +1394,7 @@
+ 
+   printf ("// Input operand strings: %s %s %s\n", istr1, istr2, istr3);
+   fail_res++;
+-  sprintf (line, "%s %s %s %s\n", func, op1, op2, op3);
++  snprintf (line, 1024, "%s %s %s %s\n", func, op1, op2, op3);
+     printf ("// Ulp error: %e\n", ulp+ulp_add);
+       printf ("// Full input string: %s\n", full_line);
+     printf ("// Input string number: %d\n", line_counter);
+Index: intelrdfpmath-2.0u2/TESTS/makefile
+===================================================================
+--- intelrdfpmath-2.0u2.orig/TESTS/makefile
++++ intelrdfpmath-2.0u2/TESTS/makefile
+@@ -78,7 +78,7 @@
+ ifeq ($(CC),icc)
+ COPT = -Werror -Qoption,cpp,--extended_float_types
+ else
+-COPT = -Werror
++COPT = -Werror -Wno-error=format-truncation
+ endif
+ endif
+ 

Reply via email to