Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1753732

Summary: format-overflow warning produce corrupted message for small overflow
Product: Red Hat Developer Toolset Reporter: Joe Wright <jwright>
Component: gccAssignee: Marek Polacek <mpolacek>
Status: CLOSED ERRATA QA Contact: Alexandra Petlanová Hájková <ahajkova>
Severity: medium Docs Contact:
Priority: unspecified    
Version: DTS 8.1 RHEL 7CC: ahajkova, jakub, law, mcermak, mnewsome, ohudlick, tborcin
Target Milestone: alpha   
Target Release: 9.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: devtoolset-9-gcc-9.1.1-2.4.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-12-10 07:49:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Joe Wright 2019-09-19 16:31:27 UTC
Description of problem:
- format-overflow warning produce corrupted message for short overflow. For bigger overflow a truncated version of the string is printed which is alright.

Version-Release number of selected component (if applicable):
DTS 8.0, 8.1

How reproducible:
100%

Steps to Reproduce:
1. run 'scl enable devtoolset-8 "g++ -c -O2 -Wall -Werror=format-overflow sample.c 2> out_gcc"'
2.
3.

Actual results:
format-overflow warning corruption

Expected results:


Additional info:

Comment 2 Marek Polacek 2019-09-23 23:24:09 UTC
This was fixed by

commit 92a180c651e233cb9f74e2655e001eb20a4ef4c4
Author: jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Apr 10 07:27:20 2019 +0000

            PR c++/90010
            * gimple-ssa-sprintf.c (target_to_host): Fix handling of targstr
            with strlen in between hostsz-3 and hostsz-1 inclusive when no
            translation is needed, and when translation is needed, only append
            ... if the string length is hostsz or more bytes long.  Avoid using
            strncpy or strcat.
    
            * gcc.dg/pr90010.c: New test.
    
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270246 138bc75d-0d04-0410-961f-82ee72b05
4a4

This fix was also backported to gcc-8-branch.

Comment 3 Marek Polacek 2019-09-24 17:08:43 UTC
Fixed in DTS 9 gcc.

Comment 7 errata-xmlrpc 2019-12-10 07:49:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2019:4134