Problem 564

Summary: Buffer overflow with long file names in G4eIonisationParameters
Product: Geant4 Reporter: azoglauer
Component: processes/electromagnetic/lowenergyAssignee: Vladimir.Ivantchenko
Status: RESOLVED FIXED    
Severity: critical CC: azoglauer
Priority: P2    
Version: other   
Hardware: PC   
OS: Linux   

Description azoglauer 2004-01-16 01:18:16 CET
This applies to Geant4 release 6.0 and probably all platforms and OSes.

In G4eIonisationParameters.cc the following code limits the file length of the
G4LEDATA (ionisation part) to 100 characters:

l. 188 ff:

    char nameChar[100] = {""};
    std::ostrstream ost(nameChar, 100, std::ios::out);
    ost << pathString << Z << ".dat";
    G4String name(nameChar);

I have no idea why the ostrstream has been initialized with a char array.
If this is important one should increase the character size to at least 1000:

    char nameChar[1000] = {""};
    std::ostrstream ost(nameChar, 1000, std::ios::out);

If there has been no good reason to initialize the ostrstream with an array, a
nicer alternative would be:

    std::ostrstream ost;
    ost << pathString << Z << ".dat";
    G4String name(nameChar);

I have tested both version successfully on debian linux.

Let me know, when the problem is fixed.

Andreas Zoglauer
Comment 1 Vladimir.Ivantchenko 2004-02-17 04:30:59 CET
Andreas is absolutly right. Bug is fixed will be in the reference versions
Comment 2 Vladimir.Ivantchenko 2004-02-17 06:57:59 CET
Fixed