Skip to content

Commit

Permalink
Fix boundary checking error in markup search, that could cause buffer…
Browse files Browse the repository at this point in the history
… over-read with corrupt input
  • Loading branch information
bfabiszewski committed May 3, 2022
1 parent 1297ee0 commit 1e0378e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions ChangeLog
@@ -1,3 +1,4 @@
2022-05-03: Fix boundary checking error in markup search, that could cause buffer over-read with corrupt input
2022-05-02: Fix typo in macro name
2022-04-27: Fix undefined behavior when passing null to strdup
2022-04-27: Fix wrong boundary checks in inflections parser resulting in stack buffer over-read with corrupt input
Expand Down
6 changes: 3 additions & 3 deletions src/parse_rawml.c
Expand Up @@ -107,7 +107,7 @@ MOBI_RET mobi_search_links_kf7(MOBIResult *result, const unsigned char *data_sta
result->value[i++] = (char) *data++;
}
/* self closing tag '/>' */
if (*(data - 1) == '/' && *data == '>') {
if (data <= data_end && *(data - 1) == '/' && *data == '>') {
--data; --i;
}
result->end = data;
Expand Down Expand Up @@ -182,7 +182,7 @@ MOBI_RET mobi_find_attrvalue(MOBIResult *result, const unsigned char *data_start
result->value[i++] = (char) *data++;
}
/* self closing tag '/>' */
if (*(data - 1) == '/' && *data == '>') {
if (data <= data_end && *(data - 1) == '/' && *data == '>') {
--data; --i;
}
result->end = data;
Expand Down Expand Up @@ -354,7 +354,7 @@ size_t mobi_get_attribute_value(char *value, const unsigned char *data, const si
length--;
}
/* self closing tag '/>' */
if (*(data - 1) == '/' && *data == '>') {
if (length && *(data - 1) == '/' && *data == '>') {
value--;
}
*value = '\0';
Expand Down

1 comment on commit 1e0378e

@carnil
Copy link

@carnil carnil commented on 1e0378e May 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CVE-2022-1907 andCVE-2022-1908 areassociated with this commit.

Please sign in to comment.