View Issue Details

IDProjectCategoryView StatusLast Update
0029252Open CASCADEOCCT:Codingpublic2018-06-29 21:19
Reporterkgv Assigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
PlatformLinuxOSUbuntu 17.10 
Product Version7.2.0 
Target Version7.3.0Fixed in Version7.3.0 
Summary0029252: Coding rules - eliminate GCC compiler warnings -Wformat-overflow
DescriptionThe following GCC 7.2.0 compiler warnings should be eliminated.
/occt.git/src/OSD/OSD_DirectoryIterator.cxx: In member function ‘void OSD_DirectoryIterator::Next()’:
/occt.git/src/OSD/OSD_DirectoryIterator.cxx:100:6: warning: ‘%s’ directive writing up to 255 bytes into a region of size 254 [-Wformat-overflow=]
 void OSD_DirectoryIterator::Next(){
      ^~~~~~~~~~~~~~~~~~~~~
/occt.git/src/OSD/OSD_DirectoryIterator.cxx:123:13: note: ‘sprintf’ output 2 or more bytes (assuming 257) into a destination of size 255
      sprintf(full_name,"%s/%s",myPlace.ToCString(),
      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       ((struct dirent *)myEntry)->d_name);   // LD debug
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/occt.git/src/OSD/OSD_FileIterator.cxx: In member function ‘void OSD_FileIterator::Next()’:
/occt.git/src/OSD/OSD_FileIterator.cxx:176:6: warning: ‘%s’ directive writing up to 255 bytes into a region of size 254 [-Wformat-overflow=]
 void OSD_FileIterator::Next(){
      ^~~~~~~~~~~~~~~~
/occt.git/src/OSD/OSD_FileIterator.cxx:199:13: note: ‘sprintf’ output 2 or more bytes (assuming 257) into a destination of size 255
      sprintf(full_name,"%s/%s",myPlace.ToCString(),
      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       ((struct dirent *)myEntry)->d_name);   // LD debug
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

||=== Build finished: 0 error(s), 2 warning(s) (17 minute(s), 37 second(s)) ===|
TagsNo tags attached.
Test case numberNot required

Relationships

related to 0029834 closedbugmaster Coding Rules - eliminate GCC compiler warnings -Wformat-overflow in IGESData_IGESWriter 

Activities

git

2017-10-21 21:17

administrator   ~0071677

Branch CR29252 has been created by kgv.

SHA-1: 5f2ddbf140ebec9e6836b287c6a3617fbdd7a8c3


Detailed log of new commits:

Author: kgv
Date: Sat Oct 21 21:17:14 2017 +0300

    0029252: Coding rules - eliminate GCC compiler warnings -Wformat-overflow
    
    OSD_DirectoryIterator and OSD_FileIterator now uses TCollection_AsciiString instead of unsafe sprintf.

kgv

2017-10-21 21:19

developer   ~0071678

Patch is ready for review.

abv

2017-10-21 22:01

manager   ~0071680

Reviewed, please test.

A side note is: function readdir used in the affected code is not reentrant; thread-safe version exist, called readdir_r.

kgv

2017-10-21 22:45

developer   ~0071682

> A side note is: function readdir used in the affected code is not reentrant;
> thread-safe version exist, called readdir_r.
readdir_r has bad design and is deprecated within glibc:
http://man7.org/linux/man-pages/man3/readdir_r.3.html

bugmaster

2017-10-24 16:09

administrator   ~0071748

Combination -
OCCT branch : CR29252 SHA-1: 5f2ddbf140ebec9e6836b287c6a3617fbdd7a8c3
Products branch : master
was compiled on Linux, MacOS and Windows platforms and tested on optimize mode on jenkins-test-10 and jenkins-tets-08.

Number of compiler warnings:
No new/fixed warnings

Regressions/Differences/Improvements:
No regressions/differences

CPU differences:
No differences that require special attention

Image differences :
No differences that require special attention

Memory differences :
No differences that require special attention

git

2017-11-08 18:24

administrator   ~0072080

Branch CR29252 has been deleted by kgv.

SHA-1: 5f2ddbf140ebec9e6836b287c6a3617fbdd7a8c3

Related Changesets

occt: master 65ada1f1

2017-10-21 18:17:14

kgv


Committer: bugmaster Details Diff
0029252: Coding rules - eliminate GCC compiler warnings -Wformat-overflow

OSD_DirectoryIterator and OSD_FileIterator now uses TCollection_AsciiString instead of unsafe sprintf.
Affected Issues
0029252
mod - src/OSD/OSD_DirectoryIterator.cxx Diff File
mod - src/OSD/OSD_FileIterator.cxx Diff File

Issue History

Date Modified Username Field Change
2017-10-21 21:07 kgv New Issue
2017-10-21 21:07 kgv Assigned To => kgv
2017-10-21 21:08 kgv OS Ubuntu 17.04 => Ubuntu 17.10
2017-10-21 21:10 kgv Description Updated
2017-10-21 21:17 git Note Added: 0071677
2017-10-21 21:19 kgv Note Added: 0071678
2017-10-21 21:19 kgv Assigned To kgv => abv
2017-10-21 21:19 kgv Status new => resolved
2017-10-21 22:01 abv Note Added: 0071680
2017-10-21 22:01 abv Assigned To abv => bugmaster
2017-10-21 22:01 abv Status resolved => reviewed
2017-10-21 22:45 kgv Note Added: 0071682
2017-10-24 16:09 bugmaster Note Added: 0071748
2017-10-24 16:09 bugmaster Status reviewed => tested
2017-10-24 18:50 bugmaster Test case number => Not required
2017-10-27 09:54 bugmaster Changeset attached => occt master 65ada1f1
2017-10-27 09:54 bugmaster Status tested => verified
2017-10-27 09:54 bugmaster Resolution open => fixed
2017-11-08 18:24 git Note Added: 0072080
2018-02-20 12:58 aiv Target Version 7.4.0 => 7.3.0
2018-06-02 14:24 kgv Relationship added related to 0029834
2018-06-29 21:13 aiv Fixed in Version => 7.3.0
2018-06-29 21:19 aiv Status verified => closed