]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/filepath: add empty path check
authorPatrick Donnelly <pdonnell@ibm.com>
Thu, 14 Nov 2024 18:33:11 +0000 (13:33 -0500)
committerPatrick Donnelly <pdonnell@ibm.com>
Mon, 17 Mar 2025 19:43:15 +0000 (15:43 -0400)
When passing an empty string to filepath, it would test if the first character
is '/' which is an invalid access through std::string_view.

Signed-off-by: Patrick Donnelly <pdonnell@ibm.com>
Fixes: https://tracker.ceph.com/issues/66373
(cherry picked from commit e62fce4ec98ab03d9e71bd6e49bf2d8568a8fe71)

src/include/filepath.h

index d0965ad0cf954376f5a10c01f79f69fd172e4616..dcdfe76e7974b94b89c2dbe4416d36c7e6b44da4 100644 (file)
@@ -98,7 +98,7 @@ class filepath {
     ino = b;
   }
   void set_path(std::string_view s) {
-    if (s[0] == '/') {
+    if (!s.empty() && s[0] == '/') {
       path = s.substr(1);
       ino = 1;
     } else {