Skip to content

Commit

Permalink
WIP encode r11: protect from wrong tbl->number
Browse files Browse the repository at this point in the history
  • Loading branch information
rurban committed Dec 16, 2023
1 parent 6fea08e commit d8cba67
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4634,6 +4634,11 @@ encode_preR13_section (const Dwg_Section_Type_r11 id, Bit_Chain *restrict dat,
num = ref ? ref->index : 0; \
} \
LOG_TRACE ("\nctrl " #token " [%d]: num:%u\n", num, tblnum)
if (num + tblnum >= dwg->num_objects)
{
LOG_ERROR ("Invalid num %u + tblnum %u", (unsigned)num, (unsigned)tblnum);
return DWG_ERR_INVALIDTYPE;
}

#define PREP_TABLE(token) \
size_t pvzadr = dat->byte; \
Expand All @@ -4642,6 +4647,8 @@ encode_preR13_section (const Dwg_Section_Type_r11 id, Bit_Chain *restrict dat,
if (!obj) \
{ \
LOG_ERROR ("No table %s after pos %u found", #token, num + i); \
if (num + i > dwg->num_objects) \
num = 0; \
continue; \
} \
_obj = obj->tio.object->tio.token; \
Expand Down

0 comments on commit d8cba67

Please sign in to comment.