Skip to content

Commit bc39564

Browse files
committed
Fix substring indexing crash
* With the right input the do/while loop is executed with size == 0` leading to an unsigned integer underflow indexer-worker: Error: terminate called after throwing an instance of 'std::length_error' indexer-worker: Error: what(): basic_string::_M_create indexer-worker(user)<640260><mmnkFF9EdWYAxQkAaoL48g:6A7sFV9EdWYExQkAaoL48g>: Fatal: master: service(indexer-worker): child 640260 killed with signal 6 (core dumped)
1 parent 2fe0adc commit bc39564

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/fts-backend-flatcurve-xapian.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ fts_flatcurve_xapian_index_header(struct flatcurve_fts_backend_update_context *c
12841284
size -= csize;
12851285
} while (fuser->set.substring_search &&
12861286
(size >= 0) &&
1287-
(uni_utf8_strlen(p) >= fuser->set.min_term_size));
1287+
(uni_utf8_strlen_n(p, size) >= fuser->set.min_term_size));
12881288
}
12891289

12901290
void
@@ -1315,7 +1315,7 @@ fts_flatcurve_xapian_index_body(struct flatcurve_fts_backend_update_context *ctx
13151315
size -= csize;
13161316
} while (fuser->set.substring_search &&
13171317
(size >= 0) &&
1318-
(uni_utf8_strlen(p) >= fuser->set.min_term_size));
1318+
(uni_utf8_strlen_n(p, size) >= fuser->set.min_term_size));
13191319
}
13201320

13211321
void fts_flatcurve_xapian_delete_index(struct flatcurve_fts_backend *backend)

0 commit comments

Comments
 (0)