Problem 1419 - Incorrect format. Consider checking the third actual argument of the 'sprintf' function. The argument is expected to be not greater than 32-bit. defaultheprepattvalue.cc 183
Summary: Incorrect format. Consider checking the third actual argument of the 'sprintf...
Status: RESOLVED WONTFIX
Alias: None
Product: Geant4
Classification: Unclassified
Component: visualization/HepRep (show other problems)
Version: 9.6
Hardware: PC Windows
: P5 minor
Assignee: perl
URL:
Depends on:
Blocks:
 
Reported: 2012-12-31 13:18 CET by a.ramazani
Modified: 2013-11-19 19:50 CET (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description a.ramazani 2012-12-31 13:18:25 CET
Incorrect format. Consider checking the third actual argument of the 'sprintf' function. The argument is expected to be not greater than 32-bit. defaultheprepattvalue.cc 183



string DefaultHepRepAttValue::getAsString(int64 i) {
    char buffer[40];
    sprintf(buffer, CHEPREP_INT64_FORMAT, i);
    return buffer;        
}

#define CHEPREP_INT64_FORMAT "%ld"

correct  :

#define CHEPREP_INT64_FORMAT "%I64d"


test:
#include <stdio.h>
int main()
{
	long long i64=123456789012345LL;
	printf(" %I64d \n",i64);
	printf(" %ld \n",i64);
}

results:
 123456789012345
 -2045911175

I used The Best C++ static code analysis Tools "PVS-Studio 4.77" under Visual Studio 2012 to analyze the Geant4.9.6 code
There is many warnings and performance optimization so I recommend using PVS-Studio 
http://files.viva64.com/beta/PVS-Studio_setup.exe

Please correct me if I am wrong 
Thanks in Advance.
Comment 1 perl 2013-11-19 19:50:29 CET
This version of the HepRep driver will soon be deprecated.
Accordingly, we are not performing work on this version unless it is critical.
Please use /vis/open HepRepFile instead.