Menu

#71 Variable substitution adds a null terminator

v1.0.3
closed
None
5
2008-12-01
2008-10-29
Anonymous
No

If you add a environment variable in the config file

eg) log4cplus.appender.test_appender.File=${%USERPROFILE%\test.log

there will be an error "unable to open c:\documents and settings\user1 \test.log"

Solution

The function
errno_t getenv(::log4cplus::tstring& s, ::log4cplus::tstring const& name)

in the file getenv.cxx has a statement

s.assign(libvar.begin(), libvar.end());

it should be modified to

s.assign(libvar.begin(), libvar.end()-1); //exclude null terminator

Discussion

  • Václav Haisman

    Václav Haisman - 2008-10-29
    • milestone: --> v1.0.3
    • assigned_to: nobody --> wilx
    • status: open --> open-accepted
     
  • Václav Haisman

    Václav Haisman - 2008-10-29

    Ok, I am confused. There is no file named getenv.cxx in the log4cplus source, at least not in either 1.0.2 or 1.0.3 release candidates. What version of log4cplus are you using?

     
  • Václav Haisman

    Václav Haisman - 2008-12-01
    • status: open-accepted --> closed-invalid
     

Log in to post a comment.