Skip to content

Commit

Permalink
Fix substring indexing crash
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
edieterich committed Jun 21, 2024
1 parent 2fe0adc commit b7b63f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/fts-backend-flatcurve-xapian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ fts_flatcurve_xapian_index_header(struct flatcurve_fts_backend_update_context *c
size -= csize;
} while (fuser->set.substring_search &&
(size >= 0) &&
(uni_utf8_strlen(p) >= fuser->set.min_term_size));
(uni_utf8_strlen_n(p, size) >= fuser->set.min_term_size));
}

void
Expand Down Expand Up @@ -1315,7 +1315,7 @@ fts_flatcurve_xapian_index_body(struct flatcurve_fts_backend_update_context *ctx
size -= csize;
} while (fuser->set.substring_search &&
(size >= 0) &&
(uni_utf8_strlen(p) >= fuser->set.min_term_size));
(uni_utf8_strlen_n(p, size) >= fuser->set.min_term_size));
}

void fts_flatcurve_xapian_delete_index(struct flatcurve_fts_backend *backend)
Expand Down

0 comments on commit b7b63f5

Please sign in to comment.