2012/3/18 <[email protected]>:
> Author: mturk
> Date: Sun Mar 18 13:50:33 2012
> New Revision: 1302126
>
> URL: http://svn.apache.org/viewvc?rev=1302126&view=rev
> Log:
> Create valid shared memory name
>
> Modified:
> tomcat/jk/trunk/native/common/jk_shm.c
> tomcat/jk/trunk/native/iis/jk_isapi_plugin.c
>
> Modified: tomcat/jk/trunk/native/common/jk_shm.c
> URL:
> http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_shm.c?rev=1302126&r1=1302125&r2=1302126&view=diff
> ==============================================================================
> --- tomcat/jk/trunk/native/common/jk_shm.c (original)
> +++ tomcat/jk/trunk/native/common/jk_shm.c Sun Mar 18 13:50:33 2012
> @@ -153,6 +153,7 @@ int jk_shm_open(const char *fname, size_
> int rc = -1;
> int attached = 0;
> char lkname[MAX_PATH];
> + char shname[MAX_PATH] = "";
>
> JK_TRACE_ENTER(l);
> if (!jk_shm_inited_cs) {
> @@ -172,8 +173,17 @@ int jk_shm_open(const char *fname, size_
> jk_shm_map = NULL;
> jk_shm_hlock = NULL;
> if (fname) {
> + int i;
> SIZE_T shmsz = 0;
> - sprintf(lkname, "Global\\%s_MUTEX", fname);
> + snprintf(shname, MAX_PATH - 8, "Global\\%s", fname);
There is strcat(lkname, "_MUTEX") below, appending 6 more chars to the name,
so
s/ MAX_PATH - 8 / MAX_PATH - 14 /
though it is unlikely that anyone would hit MAX_PATH here.
> + for(i = 7; i < (int)strlen(shname); i++) {
> + if (!isalnum((unsigned char)shname[i]))
> + shname[i] = '_';
> + else
> + shname[i] = toupper(shname[i]);
> + }
> + strcpy(lkname, shame);
> + strcat(lkname, "_MUTEX");
> jk_shm_hlock = CreateMutex(jk_get_sa_with_null_dacl(), TRUE, lkname);
> if (jk_shm_hlock == NULL) {
> if (GetLastError() == ERROR_ALREADY_EXISTS) {
> @@ -199,11 +209,11 @@ int jk_shm_open(const char *fname, size_
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]