]> 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>
Thu, 27 Feb 2025 18:41:52 +0000 (13:41 -0500)
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
src/include/filepath.h

index 0d2358128cfafb79c9d2503c0a2f475391df8c56..9379cb583280fc926aa466fd2fda304fe6e927bc 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 {