From 5b5b9012fa5a958fb7b4d1f17d4960e3f1e76b58 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Sun, 17 Nov 2013 14:18:25 +0000 Subject: Close https://issues.apache.org/bugzilla/show_bug.cgi?id=53996 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1542728 13f79535-47bb-0310-9956-ffa450edef68 --- shmem/unix/shm.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'shmem') diff --git a/shmem/unix/shm.c b/shmem/unix/shm.c index f907000c8..27a29e67c 100644 --- a/shmem/unix/shm.c +++ b/shmem/unix/shm.c @@ -21,6 +21,7 @@ #include "apr_errno.h" #include "apr_user.h" #include "apr_strings.h" +#include "apr_hash.h" static apr_status_t shm_cleanup_owner(void *m_) { @@ -103,6 +104,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, #endif #if APR_USE_SHMEM_SHMGET apr_size_t nbytes; + apr_ssize_t slen; #endif #if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_SHMGET || \ APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM @@ -312,7 +314,9 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m, /* ftok() (on solaris at least) requires that the file actually * exist before calling ftok(). */ - new_m->shmkey = ftok(filename, 1); + slen = strlen(filename); + new_m->shmkey = ftok(filename, + (int)apr_hashfunc_default(filename, &slen)); if (new_m->shmkey == (key_t)-1) { apr_file_close(file); return errno; @@ -382,6 +386,7 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, apr_file_t *file; key_t shmkey; int shmid; + apr_ssize_t slen; #endif #if APR_USE_SHMEM_MMAP_TMP @@ -401,7 +406,9 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename, /* ftok() (on solaris at least) requires that the file actually * exist before calling ftok(). */ - shmkey = ftok(filename, 1); + slen = strlen(filename); + shmkey = ftok(filename, + (int)apr_hashfunc_default(filename, &slen)); if (shmkey == (key_t)-1) { goto shm_remove_failed; } @@ -532,6 +539,7 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, apr_status_t status; apr_file_t *file; /* file where metadata is stored */ apr_size_t nbytes; + apr_ssize_t slen; new_m = apr_palloc(pool, sizeof(apr_shm_t)); @@ -554,7 +562,9 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m, new_m->filename = apr_pstrdup(pool, filename); new_m->pool = pool; - new_m->shmkey = ftok(filename, 1); + slen = strlen(filename); + new_m->shmkey = ftok(filename, + (int)apr_hashfunc_default(filename, &slen)); if (new_m->shmkey == (key_t)-1) { return errno; } -- cgit v1.2.1