]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3449: pt3: shm_open can fail with a mangled path
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 4 Jan 2012 22:55:08 +0000 (11:55 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 4 Jan 2012 22:55:08 +0000 (11:55 +1300)
src/ipc/mem/Segment.cc

index 832261338caa6ac5082a55885b3cb4759c5f30c5..b9cfa6b2f31d06680a867f185bb7c7d66b74c79f 100644 (file)
@@ -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, '/')) {