memset (ui, 0, sizeof (struct pex64_unwind_info));
- if (ex_dta >= ex_dta_end || ex_dta + 4 > ex_dta_end)
+ if (ex_dta_end - ex_dta < 4)
return false;
ui->Version = PEX64_UWI_VERSION (ex_ui->Version_Flags);
ui->rawUnwindCodes = ex_dta + 4;
ui->rawUnwindCodesEnd = ex_dta_end;
- ex_dta += ui->SizeOfBlock;
- if (ex_dta > ex_dta_end)
+ if ((size_t) (ex_dta_end - ex_dta) < ui->SizeOfBlock)
return false;
+ ex_dta += ui->SizeOfBlock;
switch (ui->Flags)
{
case UNW_FLAG_CHAININFO:
- if (ex_dta + 12 > ex_dta_end)
+ if (ex_dta_end - ex_dta < 12)
return false;
ui->rva_BeginAddress = bfd_get_32 (abfd, ex_dta + 0);
ui->rva_EndAddress = bfd_get_32 (abfd, ex_dta + 4);
case UNW_FLAG_EHANDLER:
case UNW_FLAG_UHANDLER:
case UNW_FLAG_FHANDLER:
- if (ex_dta + 4 > ex_dta_end)
+ if (ex_dta_end - ex_dta < 4)
return false;
ui->rva_ExceptionHandler = bfd_get_32 (abfd, ex_dta);
ui->SizeOfBlock += 4;
i = 0;
- if (ui->rawUnwindCodes + ui->CountOfCodes * 2 > ui->rawUnwindCodesEnd)
+ if ((size_t) (ui->rawUnwindCodesEnd - ui->rawUnwindCodes)
+ < ui->CountOfCodes * 2)
{
fprintf (file, _("warning: corrupt unwind data\n"));
return;
case UWOP_ALLOC_LARGE:
if (info == 0)
{
- if (dta + 4 > ui->rawUnwindCodesEnd)
+ if (ui->rawUnwindCodesEnd - dta < 4)
{
fprintf (file, _("warning: corrupt unwind data\n"));
return;
}
else
{
- if (dta + 6 > ui->rawUnwindCodesEnd)
+ if (ui->rawUnwindCodesEnd - dta < 6)
{
fprintf (file, _("warning: corrupt unwind data\n"));
return;
break;
case UWOP_SAVE_NONVOL:
- if (dta + 4 > ui->rawUnwindCodesEnd)
+ if (ui->rawUnwindCodesEnd - dta < 4)
{
fprintf (file, _("warning: corrupt unwind data\n"));
return;
break;
case UWOP_SAVE_NONVOL_FAR:
- if (dta + 6 > ui->rawUnwindCodesEnd)
+ if (ui->rawUnwindCodesEnd - dta < 6)
{
fprintf (file, _("warning: corrupt unwind data\n"));
return;
case UWOP_SAVE_XMM:
if (ui->Version == 1)
{
- if (dta + 4 > ui->rawUnwindCodesEnd)
+ if (ui->rawUnwindCodesEnd - dta < 4)
{
fprintf (file, _("warning: corrupt unwind data\n"));
return;
break;
case UWOP_SAVE_XMM_FAR:
- if (dta + 6 > ui->rawUnwindCodesEnd)
+ if (ui->rawUnwindCodesEnd - dta < 6)
{
fprintf (file, _("warning: corrupt unwind data\n"));
return;
break;
case UWOP_SAVE_XMM128:
- if (dta + 4 > ui->rawUnwindCodesEnd)
+ if (ui->rawUnwindCodesEnd - dta < 4)
{
fprintf (file, _("warning: corrupt unwind data\n"));
return;
break;
case UWOP_SAVE_XMM128_FAR:
- if (dta + 6 > ui->rawUnwindCodesEnd)
+ if (ui->rawUnwindCodesEnd - dta < 6)
{
fprintf (file, _("warning: corrupt unwind data\n"));
return;