apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 41659] New: - apr_os_locale_encoding(): retval of nl_langinfo() should be strdup'ed somehow
Date Tue, 20 Feb 2007 08:08:28 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41659>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41659

           Summary: apr_os_locale_encoding(): retval of nl_langinfo() should
                    be strdup'ed somehow
           Product: APR
           Version: HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: moriyoshi@at.wakwak.com


Whilst I didn't ever meet a problem caused by this, I spotted a possible flaw in
apr_os_locale_encoding() as shown in the following part:

--- 
APR_DECLARE(const char*) apr_os_locale_encoding (apr_pool_t *pool)
{
#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
    const char *charset;

    charset = nl_langinfo(CODESET);
    if (charset && *charset) {
#ifdef _OSD_POSIX /* Bug workaround - delete as soon as fixed in OSD_POSIX */
        /* Some versions of OSD_POSIX return nl_langinfo(CODESET)="^[nN]" */
        /* Ignore the bogus information and use apr_os_default_encoding() */
        if (charset[0] != '^')
#endif
        return charset;
    }
#endif

    return apr_os_default_encoding(pool);
}
--- 

As stated in the nl_langinfo() spec
(http://www.opengroup.org/onlinepubs/009695399/functions/nl_langinfo.html ), the
pointer returned by nl_langinfo() may be transient and subject to race
conditions as well, so it's better off duplicating it instead of returning the
original one.

HTH,
Moriyoshi

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message