From: Amos Jeffries Date: Tue, 17 Jan 2012 08:41:18 +0000 (-0700) Subject: Bug 3449: pt3: shm_open can fail with a mangled path X-Git-Tag: SQUID_3_2_0_15~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5fb71e8bf8307710d39b074031729785e9f4cb1;p=thirdparty%2Fsquid.git Bug 3449: pt3: shm_open can fail with a mangled path --- diff --git a/src/ipc/mem/Segment.cc b/src/ipc/mem/Segment.cc index 832261338c..b9cfa6b2f3 100644 --- a/src/ipc/mem/Segment.cc +++ b/src/ipc/mem/Segment.cc @@ -178,9 +178,15 @@ Ipc::Mem::Segment::statSize(const char *context) const String Ipc::Mem::Segment::GenerateName(const char *id) { - assert(BasePath); + assert(BasePath && *BasePath); static const bool nameIsPath = shm_portable_segment_name_is_path(); - String name(nameIsPath ? BasePath : "/squid-"); + String name; + if (nameIsPath) { + name.append(BasePath); + if (name[name.size()-1] != '/') + name.append('/'); + } else + name.append("/squid-"); // append id, replacing slashes with dots for (const char *slash = strchr(id, '/'); slash; slash = strchr(id, '/')) { diff --git a/src/tests/testRock.cc b/src/tests/testRock.cc index 600fe828dc..1b604c4e07 100644 --- a/src/tests/testRock.cc +++ b/src/tests/testRock.cc @@ -41,7 +41,7 @@ testRock::setUp() throw std::runtime_error("Failed to clean test work directory"); // use current directory for shared segments (on path-based OSes) - Ipc::Mem::Segment::BasePath = ""; + Ipc::Mem::Segment::BasePath = "."; Store::Root(new StoreController);