Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-128

Passing invalid argument to ::putenv function

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Duplicate
    • 0.9.7
    • 0.10.0
    • None
    • None
    • Linux

    Description

      putenv manual states that variable passed to the function will not be copied and will be kept as is. Thus programers should not try to modify it later.
      log4cxx does even worse thing - it passes argument which is than deallocated. System uses freed space every time log4cxx functions are called.

      timezone.cpp:

      TimeZone::TimeZone(const String& ID)
      : ID(ID), rawOffset(0), DSTSavings(0)
      {
      String timeZoneEnv = _T("TZ=") + ID;

      USES_CONVERSION;
      ::putenv((char *)T2A(timeZoneEnv.c_str()));

      ...
      }
      // at this point timeZoneEnv.c_str() is deleted but still kept and referenced in programs environment

      Bug can be easly spotted using valgrind software.

      Attachments

        Activity

          People

            carnold@apache.org Curt Arnold
            l_heldt Lukasz Heldt
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: