Check length before comparing strings (#28112)

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
pull/28177/head
cai.zhang 2023-11-04 10:04:29 +08:00 committed by GitHub
parent 5fae32f77e
commit 355fcc350d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -77,6 +77,9 @@ GetDatasetLims(const DatasetPtr& dataset) {
inline bool
PrefixMatch(const std::string_view str, const std::string_view prefix) {
if (prefix.length() > str.length()) {
return false;
}
auto ret = strncmp(str.data(), prefix.data(), prefix.length());
if (ret != 0) {
return false;