Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 654724 - media-video/smplayer-18.4.0 with GCC 8.1 - mongoose.c:8370:65: error: ‘%s’ directive output may be truncated writing up to 8191 bytes into a region of size 500 [-Werror=format-truncation=]
Summary: media-video/smplayer-18.4.0 with GCC 8.1 - mongoose.c:8370:65: error: ‘%s’ di...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Qt Bug Alias
URL: https://sourceforge.net/p/smplayer/bu...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-03 11:58 UTC by Mike Lothian
Modified: 2019-02-23 16:55 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,463.00 KB, text/plain)
2018-05-03 11:58 UTC, Mike Lothian
Details
smplayer-18.4.0-build.log (smplayer-18.4.0-build.log,430.88 KB, text/x-log)
2018-05-04 09:26 UTC, Ivan
Details
Turn error diagnostics into warning for false positive (smplayer-gcc-8.patch,1.33 KB, patch)
2018-05-06 06:15 UTC, Martin Väth
Details | Diff
Remove -Werror which should not be in production code (file_654724.txt,574 bytes, patch)
2018-05-07 05:08 UTC, Martin Väth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Lothian 2018-05-03 11:58:38 UTC
As soon as a blocker bug appears for GCC 8.1 I'll add this to that

Upstream bug: https://sourceforge.net/p/smplayer/bugs/882/

x86_64-pc-linux-gnu-g++ -c -O2 -march=native -pipe -Wall -W -D_REENTRANT -fPIC -DSINGLE_INSTANCE -DFIND_SUBTITLES -DVIDEOPREVIEW -DYOUTUBE_SUPPORT -DBLURAY_SUPPORT -DTV_SUPPORT -DGUI_CHANGE_ON_RUNTIME -DLOG_MPLAYER -DLOG_SMPLAYER -DDEFAULTGUI -DMINIGUI -DMPCGUI -DSKINS -DMPRIS2 -DBOOKMARKS -DMOUSE_GESTURES -DGLOBALSHORTCUTS -DADD_BLACKBORDERS_FS -DINITIAL_BLACKBORDERS -DCHROMECAST_SUPPORT -DMPV_SUPPORT -DMPLAYER_SUPPORT -DMPLAYER2_SUPPORT -DHDPI_SUPPORT -DDOWNLOAD_SUBS -DYT_USE_SCRIPT -DYT_USE_SIG -DDATA_PATH=\"/usr/share/smplayer\" -DDOC_PATH=\"/usr/share/doc/smplayer-18.4.0\" -DTRANSLATION_PATH=\"/usr/share/smplayer/translations\" -DTHEMES_PATH=\"/usr/share/smplayer/themes\" -DSHORTCUTS_PATH=\"/usr/share/smplayer/shortcuts\" -DNO_DEBUG_ON_CONSOLE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_XML_LIB -DQT_SCRIPT_LIB -DQT_DBUS_LIB -DQT_CORE_LIB -I. -Ifindsubtitles -Ifindsubtitles/maia -Ifindsubtitles/filedownloader -Iyoutube -Impcgui -Iskingui -Impris2 -Ivideopreview -isystem /usr/include/qt5/QtSolutions -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui/5.10.1 -isystem /usr/include/qt5/QtGui/5.10.1/QtGui -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtXml -isystem /usr/include/qt5/QtScript -isystem /usr/include/qt5/QtDBus -isystem /usr/include/qt5/QtCore/5.10.1 -isystem /usr/include/qt5/QtCore/5.10.1/QtCore -isystem /usr/include/qt5/QtCore -I.moc -isystem /usr/include/libdrm -I.ui -I/usr/lib64/qt5/mkspecs/linux-g++ -o .obj/extensions.o extensions.cpp
mongoose.c: In function ‘mg_send_ssi_file.part.42’:
mongoose.c:8370:65: error: ‘%s’ directive output may be truncated writing up to 8191 bytes into a region of size 500 [-Werror=format-truncation=]
     snprintf(path + strlen(path), sizeof(path) - strlen(path), "%s", file_name);
                                                                 ^~   ~~~~~~~~~
mongoose.c:8370:5: note: ‘snprintf’ output between 1 and 8192 bytes into a destination of size 500
     snprintf(path + strlen(path), sizeof(path) - strlen(path), "%s", file_name);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mongoose.c:8362:35: error: ‘%s’ directive output may be truncated writing up to 8191 bytes into a region of size 500 [-Werror=format-truncation=]
     snprintf(path, sizeof(path), "%s", file_name);
                                   ^~   ~~~~~~~~~
mongoose.c:8362:5: note: ‘snprintf’ output between 1 and 8192 bytes into a destination of size 500
     snprintf(path, sizeof(path), "%s", file_name);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mongoose.c:8356:38: error: ‘%s’ directive output may be truncated writing up to 8191 bytes into a region of size 499 [-Werror=format-truncation=]
     snprintf(path, sizeof(path), "%s/%s", opts->document_root, file_name);
                                      ^~                        ~~~~~~~~~
mongoose.c:8356:5: note: ‘snprintf’ output 2 or more bytes (assuming 8193) into a destination of size 500
     snprintf(path, sizeof(path), "%s/%s", opts->document_root, file_name);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subtracks.cpp: In member function ‘void SubTracks::list()’:
subtracks.cpp:46:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
  for (unsigned int n=0; n < subs.count(); n++) {
                         ~~^~~~~~~~~~~~~~
subtracks.cpp: In member function ‘void SubTracks::listNames()’:
subtracks.cpp:54:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
  for (unsigned int n=0; n < subs.count(); n++) {
                         ~~^~~~~~~~~~~~~~
subtracks.cpp: In member function ‘int SubTracks::find(SubData::Type, int)’:
subtracks.cpp:118:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
  for (unsigned int n=0; n < subs.count(); n++) {
                         ~~^~~~~~~~~~~~~~
x86_64-pc-linux-gnu-g++ -c -O2 -march=native -pipe -Wall -W -D_REENTRANT -fPIC -DSINGLE_INSTANCE -DFIND_SUBTITLES -DVIDEOPREVIEW -DYOUTUBE_SUPPORT -DBLURAY_SUPPORT -DTV_SUPPORT -DGUI_CHANGE_ON_RUNTIME -DLOG_MPLAYER -DLOG_SMPLAYER -DDEFAULTGUI -DMINIGUI -DMPCGUI -DSKINS -DMPRIS2 -DBOOKMARKS -DMOUSE_GESTURES -DGLOBALSHORTCUTS -DADD_BLACKBORDERS_FS -DINITIAL_BLACKBORDERS -DCHROMECAST_SUPPORT -DMPV_SUPPORT -DMPLAYER_SUPPORT -DMPLAYER2_SUPPORT -DHDPI_SUPPORT -DDOWNLOAD_SUBS -DYT_USE_SCRIPT -DYT_USE_SIG -DDATA_PATH=\"/usr/share/smplayer\" -DDOC_PATH=\"/usr/share/doc/smplayer-18.4.0\" -DTRANSLATION_PATH=\"/usr/share/smplayer/translations\" -DTHEMES_PATH=\"/usr/share/smplayer/themes\" -DSHORTCUTS_PATH=\"/usr/share/smplayer/shortcuts\" -DNO_DEBUG_ON_CONSOLE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_XML_LIB -DQT_SCRIPT_LIB -DQT_DBUS_LIB -DQT_CORE_LIB -I. -Ifindsubtitles -Ifindsubtitles/maia -Ifindsubtitles/filedownloader -Iyoutube -Impcgui -Iskingui -Impris2 -Ivideopreview -isystem /usr/include/qt5/QtSolutions -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui/5.10.1 -isystem /usr/include/qt5/QtGui/5.10.1/QtGui -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtXml -isystem /usr/include/qt5/QtScript -isystem /usr/include/qt5/QtDBus -isystem /usr/include/qt5/QtCore/5.10.1 -isystem /usr/include/qt5/QtCore/5.10.1/QtCore -isystem /usr/include/qt5/QtCore -I.moc -isystem /usr/include/libdrm -I.ui -I/usr/lib64/qt5/mkspecs/linux-g++ -o .obj/desktopinfo.o desktopinfo.cpp
x86_64-pc-linux-gnu-g++ -O2 -march=native -pipe -Wall -W -dM -E -o .moc/moc_predefs.h /usr/lib64/qt5/mkspecs/features/data/dummy.cpp
mongoose.c: In function ‘mg_resolve_async_opt’:
mongoose.c:10791:3: error: ‘strncpy’ specified bound 1024 equals destination size [-Werror=stringop-truncation]
   strncpy(req->name, name, sizeof(req->name));
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comment 1 Mike Lothian 2018-05-03 11:58:58 UTC
Created attachment 529566 [details]
build.log
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2018-05-03 12:12:28 UTC
I think this should also fail with GCC 7.
Comment 3 Ivan 2018-05-04 09:22:36 UTC
(In reply to Jeroen Roovers from comment #2)
> I think this should also fail with GCC 7.

In my case it does build fine with GCC-7.3.0-r1

And, of course, it doesn't work with GCC-8.1.0 and GCC-8.1.0-r1

Portage 2.3.34 (python 3.6.5-final-0, default/linux/amd64/17.1/desktop/plasma, gcc-8.1.0, glibc-2.26-r6, 4.16.7-gentoo x86_64)
=================================================================
System uname: Linux-4.16.7-gentoo-x86_64-Intel-R-_Core-TM-_i7-4930K_CPU_@_3.40GHz-with-gentoo-2.4.1
KiB Mem:    16352972 total,   2803896 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Thu, 03 May 2018 22:30:01 +0000
Head commit of repository gentoo: df0dabac3240e22373ce1533da6b244ceba76fe2
sh bash 4.4_p19
ld GNU ld (Gentoo 2.30 p2) 2.30.0
app-shells/bash:          4.4_p19::gentoo
dev-lang/perl:            5.26.2::gentoo
dev-lang/python:          2.7.14-r2::gentoo, 3.6.5-r1::gentoo
dev-util/cmake:           3.11.1::gentoo
dev-util/pkgconfig:       0.29.2::gentoo
sys-apps/baselayout:      2.4.1-r2::gentoo
sys-apps/openrc:          0.35.5::gentoo
sys-apps/sandbox:         2.13::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69-r4::gentoo
sys-devel/automake:       1.13.4-r2::gentoo, 1.16.1-r1::gentoo
sys-devel/binutils:       2.30-r2::gentoo
sys-devel/gcc:            7.3.0-r1::gentoo, 8.1.0-r1::gentoo
sys-devel/gcc-config:     1.9.1::gentoo
sys-devel/libtool:        2.4.6-r5::gentoo
sys-devel/make:           4.2.1-r3::gentoo
sys-kernel/linux-headers: 4.16-r1::gentoo (virtual/os-headers)
sys-libs/glibc:           2.26-r6::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts: 

my
    location: /usr/local/my
    masters: gentoo
    priority: 0

deadbeef-overlay
    location: /var/lib/layman/deadbeef-overlay
    masters: gentoo
    priority: 50

hamper-overlay
    location: /var/lib/layman/hamper-overlay
    masters: gentoo
    priority: 50

linxon
    location: /var/lib/layman/linxon
    masters: gentoo
    priority: 50

mozilla
    location: /var/lib/layman/mozilla
    masters: gentoo
    priority: 50

reagentoo
    location: /var/lib/layman/reagentoo
    masters: gentoo
    priority: 50

scrill
    location: /var/lib/layman/scrill
    masters: gentoo
    priority: 50

steam-overlay
    location: /var/lib/layman/steam-overlay
    masters: gentoo
    priority: 50

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -mtune=native -O2 -pipe -fomit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -mtune=native -O2 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps=y --quiet-build=n"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync metadata-transfer multilib-strict news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="ru_RU.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="ru en"
MAKEOPTS="-j12"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/tmp"
USE="X a52 aac acl acpi activities aes aften alsa amd64 amr ass audio avx bash-completion branding bzip2 cairo cdda cdr clang cleartype cracklib crypt css cups cxx dbus declarative device-mapper djvu dri dts dv dvd dvdr egl elogind encode exif faac faad fam fat ffmpeg firmware-loader flac fontconfig gd gif glamor gles gpm gzip iconv icu id3tag ieee1394 imagemagick ipv6 jit jpeg kde keymap ladspa lame lash lcms libass libnotify lm_sensors lzma lzo mad matroska midi mmx mmxext mng modules mp3 mp4 mpeg mplayer mtp mudflap multilib ncurses nls nptl ntfs nvidia ogg opengl openmp opus pam pango pcre pdf phonon pie plasma png policykit popcnt ppds pppd pulseaudio qml qt5 quicktime rar raw readline scanner sdl seccomp session sse sse2 sse3 sse4_1 sse4_2 ssl ssp ssse3 startup-notification svc svg sysfs system-binutils system-boost system-cairo system-clang system-ffmpeg system-harfbuzz system-icu system-jpeg system-libevent system-libvpx system-llvm system-sql tcpd theora threads tiff toolame truetype twolame udev udisks unicode upower usb vaapi vdpau vorbis vpx wav wavpack wayland widgets win32codecs wxwidgets x264 x265 xattr xcb xcomposite xml xorg xscreensaver xulrunner xv xvfb xvid xvmc zip zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon plan sheets stage words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx f16c mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" L10N="ru en" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-6 php7-0" POSTGRES_TARGETS="postgres9_5" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" RUBY_TARGETS="ruby22 ruby23" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, ENV_UNSET, INSTALL_MASK, LC_ALL, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 4 Ivan 2018-05-04 09:26:54 UTC
Created attachment 529712 [details]
smplayer-18.4.0-build.log

Build with USE="-autoshutdown -bidi -debug -mpris"
Comment 5 Martin Väth 2018-05-06 06:15:42 UTC
Created attachment 530068 [details, diff]
Turn error diagnostics into warning for false positive

I suspect that the limits in gcc-8 for printing the diagnostics in the default might be stricter. Therefore, I guess to block this bug against gcc-8 might be appropriate.

I attach a patch which simply turns the diagnostics into a warning (which IMHO it should have been in the first place).

This patch might fail for gcc or clang versions which do not have the option -Wformat-truncation
I have not investigated whether there are such versions.
Comment 6 Ivan 2018-05-06 13:24:37 UTC
(In reply to Martin Väth from comment #5)
> Created attachment 530068 [details, diff] [details, diff]
> Turn error diagnostics into warning for false positive
> 

Thanks, the patch you provided does the trick for me.

I was able to build smplayer using gcc-8.1.0-r1 with USE="-autoshutdown -bidi -debug -mpris"

It also works fine with gcc-7.3.0-r1

In the same time the patch is not suitable for llvm/clang-6.0.0-r1. It does not build with patch, but compiles and merges fine without said patch. But since this bug is related to gcc-8.1.0, I think I should not clutter it with build logs related to clang. If I should do otherwise - please let me know.
Comment 7 Martin Väth 2018-05-07 05:08:32 UTC
Created attachment 530294 [details, diff]
Remove -Werror which should not be in production code
Comment 8 Martin Väth 2018-05-07 05:19:34 UTC
My comment to my fix of the patch did not appear (probably due to a local javascript blocker) so I post it again:

As already indicated, the real bug is that a mere informative message is causing a stop of the compilation. I had previously falsely assumed that this was the compiler default (caused by e.g. the default -DFORTIFY_SOURCE=2 or something similar), but I simply had missed that for this particular file the option -Werror was passed.

Of course, while this option is useful during development, it is always wrong to use in production code for exactly that reason: An informative message is not an error, and such informative messages are strongly compiler dependent.

Therefore, the correct fix is to remove the inappropriate -Werror which is done by the new patch.
Comment 9 Helmut Jarausch 2018-05-07 09:54:20 UTC
(In reply to Martin Väth from comment #8)
> My comment to my fix of the patch did not appear (probably due to a local
> javascript blocker) so I post it again:
> 
> As already indicated, the real bug is that a mere informative message is
> causing a stop of the compilation. I had previously falsely assumed that
> this was the compiler default (caused by e.g. the default -DFORTIFY_SOURCE=2
> or something similar), but I simply had missed that for this particular file
> the option -Werror was passed.
> 
> Of course, while this option is useful during development, it is always
> wrong to use in production code for exactly that reason: An informative
> message is not an error, and such informative messages are strongly compiler
> dependent.
> 
> Therefore, the correct fix is to remove the inappropriate -Werror which is
> done by the new patch.

Sorry, but I cannot see the attachment - just a comment about it.
Comment 10 Larry the Git Cow gentoo-dev 2018-05-07 12:19:16 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e101ecc3740756d2b69c369791f6ecb4c264ae9d

commit e101ecc3740756d2b69c369791f6ecb4c264ae9d
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-05-07 12:18:57 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-05-07 12:19:08 +0000

    media-video/smplayer: drop -Werror to allow gcc-8, bug #654724
    
    gcc-8 covers even more potential buffer overflow conditions.
    This causes new build failure due to blanket -Werror in smplayer.
    
    For more details see Gentoo's take on -Werror handling in devmanual:
    https://devmanual.gentoo.org/ebuild-writing/common-mistakes/index.html
    
    Reported-by: Mike Lothian
    Closes: https://bugs.gentoo.org/654724
    Package-Manager: Portage-2.3.36, Repoman-2.3.9

 media-video/smplayer/files/smplayer-18.3.0-disable-werror.patch | 9 +++++++++
 media-video/smplayer/smplayer-18.3.0.ebuild                     | 1 +
 media-video/smplayer/smplayer-18.4.0.ebuild                     | 1 +
 3 files changed, 11 insertions(+)