From: Patrick Donnelly Date: Thu, 14 Nov 2024 18:33:11 +0000 (-0500) Subject: include/filepath: add empty path check X-Git-Tag: v19.2.3~288^2~71 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=26ecf7c4a5680431c4bc3b5a260ba2df3a5ca6a2;p=ceph.git include/filepath: add empty path check 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 Fixes: https://tracker.ceph.com/issues/66373 (cherry picked from commit e62fce4ec98ab03d9e71bd6e49bf2d8568a8fe71) --- diff --git a/src/include/filepath.h b/src/include/filepath.h index d0965ad0cf954..dcdfe76e7974b 100644 --- a/src/include/filepath.h +++ b/src/include/filepath.h @@ -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 {