| Summary: | In Vt102Emulation snprintf truncation warnings while compiling | ||
|---|---|---|---|
| Product: | [Applications] konsole | Reporter: | Ahmad Samir <a.samirh78> |
| Component: | general | Assignee: | Konsole Bugs <konsole-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | mglb |
| Priority: | NOR | ||
| Version First Reported In: | master | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | https://commits.kde.org/konsole/847b72358d6c5371e7c8119c7081139112ced728 | Version Fixed/Implemented In: | |
| Sentry Crash Report: | |||
Looking at the code this warning should always be there (first build with gcc 8?). It is also irrevelant, unless someone uses 8-digit-long terminal width/height. Increasing the buffer size to 27 will solve the problem. I'll fix this (In reply to Mariusz Glebocki from comment #1) > Looking at the code this warning should always be there (first build with > gcc 8?). First time I see that warning, could have been there before > It is also irrevelant, unless someone uses 8-digit-long terminal > width/height. OK, good to know; I wasn't sure if it were important or not so I filed a bug to track the issue / get it looked at. [...] Regards. Git commit 847b72358d6c5371e7c8119c7081139112ced728 by Kurt Hindenburg, on behalf of Mariusz Glebocki. Committed on 23/05/2018 at 23:42. Pushed by hindenburg into branch 'master'. Silence -Wformat-truncation warnings Summary: Add a few bytes to a small arrays on stack in order to make compiler happy. Those warnings are invalid in this context (as long as terminal width and height are not larger than 8-digits-long number). Test Plan: * Build Konsole with GCC 8 and `-Wformat-truncation` flag Expected result: no format-truncation warnings Actual result: three format-truncation warnings appear Reviewers: #konsole, hindenburg Reviewed By: #konsole, hindenburg Subscribers: hindenburg, konsole-devel, #konsole Tags: #konsole Differential Revision: https://phabricator.kde.org/D13080 M +2 -2 src/Vt102Emulation.cpp https://commits.kde.org/konsole/847b72358d6c5371e7c8119c7081139112ced728 |
Possibly related to this change[1]; I got this compiling current git master: /home/builder/rpmbuild/konsole5/konsole5-f27/BUILD/konsole-18.07.70/src/Vt102Emulation.cpp: In member function 'void Konsole::Vt102Emulation::reportCursorPosition()': /home/builder/rpmbuild/konsole5/konsole5-f27/BUILD/konsole-18.07.70/src/Vt102Emulation.cpp:955:30: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size between 6 and 16 [-Wformat-truncation=] snprintf(tmp, sizeof(tmp), "\033[%d;%dR", _currentScreen->getCursorY()+1, _currentScreen->getCursorX()+1); ^~~~~~~~~~~~~ /home/builder/rpmbuild/konsole5/konsole5-f27/BUILD/konsole-18.07.70/src/Vt102Emulation.cpp:955:30: note: directive argument in the range [-2147483647, 2147483647] In file included from /usr/include/stdio.h:862, from /usr/include/c++/8/cstdio:42, from /usr/include/c++/8/ext/string_conversions.h:43, from /usr/include/c++/8/bits/basic_string.h:6361, from /usr/include/c++/8/string:52, from /usr/include/qt5/QtCore/qbytearray.h:52, from /usr/include/qt5/QtCore/qstring.h:49, from /usr/include/qt5/QtCore/qhashfunctions.h:44, from /usr/include/qt5/QtCore/qlist.h:47, from /usr/include/qt5/QtCore/qhash.h:46, from /usr/include/qt5/QtCore/QHash:1, from /home/builder/rpmbuild/konsole5/konsole5-f27/BUILD/konsole-18.07.70/src/Vt102Emulation.h:27, from /home/builder/rpmbuild/konsole5/konsole5-f27/BUILD/konsole-18.07.70/src/Vt102Emulation.cpp:24: /usr/include/bits/stdio2.h:64:35: note: '__builtin___snprintf_chk' output between 7 and 27 bytes into a destination of size 20 return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __bos (__s), __fmt, __va_arg_pack ()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/builder/rpmbuild/konsole5/konsole5-f27/BUILD/konsole-18.07.70/src/Vt102Emulation.cpp: In member function 'virtual void Konsole::Vt102Emulation::sendMouseEvent(int, int, int, int)': /home/builder/rpmbuild/konsole5/konsole5-f27/BUILD/konsole-18.07.70/src/Vt102Emulation.cpp:1057:44: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size between 7 and 26 [-Wformat-truncation=] snprintf(command, sizeof(command), "\033[%d;%d;%dM", cb + 0x20, cx, cy); ^~~~~~~~~~~~~~~~ /home/builder/rpmbuild/konsole5/konsole5-f27/BUILD/konsole-18.07.70/src/Vt102Emulation.cpp:1057:44: note: directive argument in the range [1, 2147483647] In file included from /usr/include/stdio.h:862, from /usr/include/c++/8/cstdio:42, from /usr/include/c++/8/ext/string_conversions.h:43, from /usr/include/c++/8/bits/basic_string.h:6361, from /usr/include/c++/8/string:52, from /usr/include/qt5/QtCore/qbytearray.h:52, from /usr/include/qt5/QtCore/qstring.h:49, from /usr/include/qt5/QtCore/qhashfunctions.h:44, from /usr/include/qt5/QtCore/qlist.h:47, from /usr/include/qt5/QtCore/qhash.h:46, from /usr/include/qt5/QtCore/QHash:1, from /home/builder/rpmbuild/konsole5/konsole5-f27/BUILD/konsole-18.07.70/src/Vt102Emulation.h:27, from /home/builder/rpmbuild/konsole5/konsole5-f27/BUILD/konsole-18.07.70/src/Vt102Emulation.cpp:24: /usr/include/bits/stdio2.h:64:35: note: '__builtin___snprintf_chk' output between 9 and 37 bytes into a destination of size 32 return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __bos (__s), __fmt, __va_arg_pack ()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [1]