diff options
| author | 2017-02-07 04:19:44 +0100 | |
|---|---|---|
| committer | 2017-02-07 04:19:44 +0100 | |
| commit | 3a5520ccce42ac145794f2195cc60e8ae855a8cb (patch) | |
| tree | de00656dd1eaf5a3aca0159254b5bac71e1be2e7 | |
| parent | 9c70a359f5786639c414c179f2d9ec9f9f245ed3 (diff) | |
| download | libplist-3a5520ccce42ac145794f2195cc60e8ae855a8cb.tar.gz libplist-3a5520ccce42ac145794f2195cc60e8ae855a8cb.tar.bz2 | |
xplist: Prevent some more strncmp related OOB reads
| -rw-r--r-- | src/xplist.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/xplist.c b/src/xplist.c index 1c166f5..e8f80fb 100644 --- a/src/xplist.c +++ b/src/xplist.c | |||
| @@ -567,7 +567,7 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, size_t tag_le | |||
| 567 | } | 567 | } |
| 568 | ctx->pos += 2; | 568 | ctx->pos += 2; |
| 569 | find_str(ctx, "-->", 3, 0); | 569 | find_str(ctx, "-->", 3, 0); |
| 570 | if (ctx->pos >= ctx->end || strncmp(ctx->pos, "-->", 3) != 0) { | 570 | if (ctx->pos > ctx->end-3 || strncmp(ctx->pos, "-->", 3) != 0) { |
| 571 | PLIST_XML_ERR("EOF while looking for end of comment\n"); | 571 | PLIST_XML_ERR("EOF while looking for end of comment\n"); |
| 572 | ctx->err++; | 572 | ctx->err++; |
| 573 | return NULL; | 573 | return NULL; |
| @@ -591,7 +591,7 @@ static text_part_t* get_text_parts(parse_ctx ctx, const char* tag, size_t tag_le | |||
| 591 | ctx->pos+=6; | 591 | ctx->pos+=6; |
| 592 | p = ctx->pos; | 592 | p = ctx->pos; |
| 593 | find_str(ctx, "]]>", 3, 0); | 593 | find_str(ctx, "]]>", 3, 0); |
| 594 | if (ctx->pos >= ctx->end || strncmp(ctx->pos, "]]>", 3) != 0) { | 594 | if (ctx->pos > ctx->end-3 || strncmp(ctx->pos, "]]>", 3) != 0) { |
| 595 | PLIST_XML_ERR("EOF while looking for end of CDATA block\n"); | 595 | PLIST_XML_ERR("EOF while looking for end of CDATA block\n"); |
| 596 | ctx->err++; | 596 | ctx->err++; |
| 597 | return NULL; | 597 | return NULL; |
| @@ -830,7 +830,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) | |||
| 830 | 830 | ||
| 831 | if (*(ctx->pos) == '?') { | 831 | if (*(ctx->pos) == '?') { |
| 832 | find_str(ctx, "?>", 2, 1); | 832 | find_str(ctx, "?>", 2, 1); |
| 833 | if (ctx->pos >= ctx->end-2) { | 833 | if (ctx->pos > ctx->end-2) { |
| 834 | PLIST_XML_ERR("EOF while looking for <? tag closing marker\n"); | 834 | PLIST_XML_ERR("EOF while looking for <? tag closing marker\n"); |
| 835 | ctx->err++; | 835 | ctx->err++; |
| 836 | goto err_out; | 836 | goto err_out; |
| @@ -847,7 +847,7 @@ static void node_from_xml(parse_ctx ctx, plist_t *plist, uint32_t depth) | |||
| 847 | if (((ctx->end - ctx->pos) > 3) && !strncmp(ctx->pos, "!--", 3)) { | 847 | if (((ctx->end - ctx->pos) > 3) && !strncmp(ctx->pos, "!--", 3)) { |
| 848 | ctx->pos += 3; | 848 | ctx->pos += 3; |
| 849 | find_str(ctx,"-->", 3, 0); | 849 | find_str(ctx,"-->", 3, 0); |
| 850 | if (strncmp(ctx->pos, "-->", 3)) { | 850 | if (ctx->pos > ctx->end-3 || strncmp(ctx->pos, "-->", 3)) { |
| 851 | PLIST_XML_ERR("Couldn't find end of comment\n"); | 851 | PLIST_XML_ERR("Couldn't find end of comment\n"); |
| 852 | ctx->err++; | 852 | ctx->err++; |
| 853 | goto err_out; | 853 | goto err_out; |
