You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2014/04/30 23:00:01 UTC

[Bug 56477] New: Saving pointer pointer to string of unknown origin.

https://issues.apache.org/bugzilla/show_bug.cgi?id=56477

            Bug ID: 56477
           Summary: Saving pointer pointer to string of unknown origin.
           Product: APR
           Version: 1.5.0
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
          Assignee: bugs@apr.apache.org
          Reporter: Harry.Tongelidis@misys.com

In the file:
https://svn.apache.org/repos/asf/apr/apr/branches/1.6.x/locks/win32/proc_mutex.c

Function:
APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex,
                                                const char *fname,
                                                apr_lockmech_e mech,
                                                apr_pool_t *pool);

The pointer to the string passed to the function is stored in the newly created
structure. 
(*mutex)->fname = fname;

This is fine for static strings but strings on the stack or dynamically
allocated will point to garbage when (*mutex)->fname is accessed.

The structure pointer is accessed in the function: 
APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex);

My guess is that:
(*mutex)->fname = fname;

Should be:
(*mutex)->fname = mutexkey;
Or:
(*mutex)->fname = fname? apr_pstrdup(pool, fname) : NULL;

-- 
You are receiving this mail because:
You are the assignee for the bug.

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