Browse code

Adjusting HWP offset check to account for the possibility of a zero-cell or zero-line situation.

Micah Snyder (micasnyd) authored on 2018/05/31 01:03:32
Showing 1 changed files
... ...
@@ -782,7 +782,7 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
782 782
     }
783 783
 #else
784 784
     new_offset = offset + (nlines * HWP3_LINEINFO_SIZE);
785
-    if ((new_offset <= offset) || (new_offset >= map->len)) {
785
+    if ((new_offset < offset) || (new_offset >= map->len)) {
786 786
         cli_errmsg("HWP3.x: Paragraph[%d, %d]: length value is too high, invalid. %u\n", level, p, nlines);
787 787
         return CL_EPARSE;
788 788
     }
... ...
@@ -1060,7 +1060,7 @@ static inline int parsehwp3_paragraph(cli_ctx *ctx, fmap_t *map, int p, int leve
1060 1060
                     hwp3_debug("HWP3.x: Paragraph[%d, %d]: box cell info array starts @ %llu\n", level, p, (long long unsigned)offset);
1061 1061
 
1062 1062
                     new_offset = offset + (27 * ncells);
1063
-                    if ((new_offset <= offset) || (new_offset >= map->len)) {
1063
+                    if ((new_offset < offset) || (new_offset >= map->len)) {
1064 1064
                         cli_errmsg("HWP3.x: Paragraph[%d, %d]: number of box cells is too high, invalid. %u\n", level, p, ncells);
1065 1065
                         return CL_EPARSE;
1066 1066
                     }