mirror of
https://github.com/frida/tinycc
synced 2024-11-27 18:19:35 +03:00
Fix bound checking for packed struct
This commit is contained in:
parent
09ed7e9557
commit
8b8e714517
6
tccgen.c
6
tccgen.c
@ -1871,9 +1871,15 @@ ST_FUNC void gaddrof(void)
|
||||
/* generate a bounded pointer addition */
|
||||
static void gen_bounded_ptr_add(void)
|
||||
{
|
||||
int save = (vtop[-1].r & VT_VALMASK) == VT_LOCAL;
|
||||
if (save) {
|
||||
vpushv(&vtop[-1]);
|
||||
vrott(3);
|
||||
}
|
||||
vpush_global_sym(&func_old_type, TOK___bound_ptr_add);
|
||||
vrott(3);
|
||||
gfunc_call(2);
|
||||
vtop -= save;
|
||||
vpushi(0);
|
||||
/* returned pointer is in REG_IRET */
|
||||
vtop->r = REG_IRET | VT_BOUNDED;
|
||||
|
@ -129,6 +129,16 @@ void tst_compare(void)
|
||||
if (tst() > 0) printf ("error\n");
|
||||
}
|
||||
|
||||
#pragma pack(1)
|
||||
struct S { int d:24; int f:14; } i, j;
|
||||
#pragma pack()
|
||||
|
||||
void tst_pack (void)
|
||||
{
|
||||
i.f = 5; j.f = 5;
|
||||
if (j.f != i.f) printf("error\n");
|
||||
}
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
@ -144,4 +154,5 @@ main (void)
|
||||
tst_adr(&sprintf);
|
||||
tst_builtin();
|
||||
tst_compare();
|
||||
tst_pack();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user