diff --git a/ChangeLog b/ChangeLog index 5d9ab5c..e385bfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +2022-05-27: Fix potential null pointer dereference on corrupt input when inflections CNCX record is not initialized 2022-05-23: Fix index entries count 2022-05-23: Prevent leak of index entries on corrupt data 2022-05-23: Add checks for fragments part in case of corrupt data diff --git a/src/index.c b/src/index.c index 322f2de..f8ad74f 100644 --- a/src/index.c +++ b/src/index.c @@ -1019,14 +1019,14 @@ MOBI_RET mobi_decode_infl(unsigned char *decoded, int *decoded_size, const unsig Matches are made agains reversed string and all its substrings @param[in,out] infl_strings Array of returned strings - @param[in,out] root Root node of the tree - @param[in,out] string Index entry number + @param[in] root Root node of the tree + @param[in] string Index entry number @return Number of returned strings */ size_t mobi_trie_get_inflgroups(char **infl_strings, MOBITrie * const root, const char *string) { /* travers trie and get values for each substring */ if (root == NULL) { - return MOBI_PARAM_ERR; + return 0; } size_t count = 0; size_t length = strlen(string); @@ -1060,11 +1060,14 @@ size_t mobi_trie_get_inflgroups(char **infl_strings, MOBITrie * const root, cons @brief Insert inversed inlection string for given entry into trie structure @param[in,out] root Root node of the tree, created if NULL - @param[in,out] indx MOBIIndx infl index records - @param[in,out] i Index entry number + @param[in] indx MOBIIndx infl index records + @param[in] i Index entry number @return MOBI_RET status code (on success MOBI_SUCCESS) */ MOBI_RET mobi_trie_insert_infl(MOBITrie **root, const MOBIIndx *indx, size_t i) { + if (indx->cncx_record == NULL) { + return MOBI_DATA_CORRUPT; + } MOBIIndexEntry e = indx->entries[i]; char *inflected = e.label; for (size_t j = 0; j < e.tags_count; j++) {