From e95d57f39c731e2cd27aa8f604db4ad96e1c3049 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Tue, 2 Jun 2015 20:51:03 +0200 Subject: [PATCH] Use ftok() for semget(), and only lower mode bits --- libraries/liblmdb/mdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 482b98e6b3..cc0944d59b 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -4548,7 +4548,10 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl) if (!env->me_wmutex) goto fail_errno; #elif defined(MDB_USE_SYSV_SEM) unsigned short vals[2] = {1, 1}; - semid = semget(IPC_PRIVATE, 2, mode); + key_t key = ftok(lpath, 'M'); + if (key == -1) + goto fail_errno; + semid = semget(key, 2, (mode & 0777) | IPC_CREAT); if (semid < 0) goto fail_errno; semu.array = vals; -- 2.39.5