MantisBT - Open CASCADE
View Issue Details
0029252Open CASCADE[OCCT] OCCT:Codingpublic2017-10-21 21:072018-06-29 21:19
kgv 
bugmaster 
normalminor 
closedfixed 
LinuxUbuntu 17.1064 bit
[OCCT] 7.2.0 
[OCCT] 7.3.0[OCCT] 7.3.0 
Not required
0029252: Coding rules - eliminate GCC compiler warnings -Wformat-overflow
The 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)) ===|
No tags attached.
related to 0029834closed bugmaster Coding Rules - eliminate GCC compiler warnings -Wformat-overflow in IGESData_IGESWriter 
Issue History
2017-10-21 21:07kgvNew Issue
2017-10-21 21:07kgvAssigned To => kgv
2017-10-21 21:08kgvOSUbuntu 17.04 => Ubuntu 17.10
2017-10-21 21:10kgvDescription Updatedbug_revision_view_page.php?rev_id=17976#r17976
2017-10-21 21:17gitNote Added: 0071677
2017-10-21 21:19kgvNote Added: 0071678
2017-10-21 21:19kgvAssigned Tokgv => abv
2017-10-21 21:19kgvStatusnew => resolved
2017-10-21 22:01abvNote Added: 0071680
2017-10-21 22:01abvAssigned Toabv => bugmaster
2017-10-21 22:01abvStatusresolved => reviewed
2017-10-21 22:45kgvNote Added: 0071682
2017-10-24 16:09bugmasterNote Added: 0071748
2017-10-24 16:09bugmasterStatusreviewed => tested
2017-10-24 18:50bugmasterTest case number => Not required
2017-10-27 09:54bugmasterChangeset attached => occt master 65ada1f1
2017-10-27 09:54bugmasterStatustested => verified
2017-10-27 09:54bugmasterResolutionopen => fixed
2017-11-08 18:24gitNote Added: 0072080
2018-02-20 12:58aivTarget Version7.4.0 => 7.3.0
2018-06-02 14:24kgvRelationship addedrelated to 0029834
2018-06-29 21:13aivFixed in Version => 7.3.0
2018-06-29 21:19aivStatusverified => closed

Notes
(0071677)
git   
2017-10-21 21:17   
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.
(0071678)
kgv   
2017-10-21 21:19   
Patch is ready for review.
(0071680)
abv   
2017-10-21 22:01   
Reviewed, please test.

A side note is: function readdir used in the affected code is not reentrant; thread-safe version exist, called readdir_r.
(0071682)
kgv   
2017-10-21 22:45   
> 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 [^]
(0071748)
bugmaster   
2017-10-24 16:09   
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
(0072080)
git   
2017-11-08 18:24   
Branch CR29252 has been deleted by kgv.

SHA-1: 5f2ddbf140ebec9e6836b287c6a3617fbdd7a8c3