Skip to content

Commit

Permalink
gac: generated code now use Int_ObjInt, not INT_INTOBJ
Browse files Browse the repository at this point in the history
Fix a potential issue in gac where `INT_INTOBJ` was called on inputs without
validation; this could lead to unexpected behavior. We now use `Int_ObjInt`
instead, which raises an error if the input is not a small integer.
  • Loading branch information
fingolfin committed Jan 2, 2020
1 parent 156e684 commit c04054b
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 77 deletions.
36 changes: 18 additions & 18 deletions src/c_oper1.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ static Obj HdlrFunc2 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -409,8 +409,8 @@ static Obj HdlrFunc2 (
}
while ( 1 ) {
if ( t_7 ) {
if ( LEN_LIST(t_8) < INT_INTOBJ(t_5) ) break;
t_6 = ELMV0_LIST( t_8, INT_INTOBJ(t_5) );
if ( LEN_LIST(t_8) < Int_ObjInt(t_5) ) break;
t_6 = ELMV0_LIST( t_8, Int_ObjInt(t_5) );
t_5 = (Obj)(((UInt)t_5)+4);
if ( t_6 == 0 ) continue;
}
Expand Down Expand Up @@ -866,8 +866,8 @@ static Obj HdlrFunc3 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -2142,8 +2142,8 @@ static Obj HdlrFunc6 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -2463,8 +2463,8 @@ static Obj HdlrFunc6 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -3320,8 +3320,8 @@ static Obj HdlrFunc8 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -3540,8 +3540,8 @@ static Obj HdlrFunc7 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -4820,8 +4820,8 @@ static Obj HdlrFunc18 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -5114,8 +5114,8 @@ static Obj HdlrFunc17 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down
34 changes: 17 additions & 17 deletions src/c_type1.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,8 @@ static Obj HdlrFunc5 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -915,7 +915,7 @@ static Obj HdlrFunc7 (
l_i = t_1;

/* if IsBound( cached![i] ) then */
t_4 = IsbPosObj( l_cached, INT_INTOBJ(l_i) ) ? True : False;
t_4 = IsbPosObj( l_cached, Int_ObjInt(l_i) ) ? True : False;
t_3 = (Obj)(UInt)(t_4 != False);
if ( t_3 ) {

Expand Down Expand Up @@ -992,8 +992,8 @@ static Obj HdlrFunc7 (
l_i = t_1;

/* if IsBound( parent![i] ) <> IsBound( cached![i] ) then */
t_4 = IsbPosObj( a_parent, INT_INTOBJ(l_i) ) ? True : False;
t_5 = IsbPosObj( l_cached, INT_INTOBJ(l_i) ) ? True : False;
t_4 = IsbPosObj( a_parent, Int_ObjInt(l_i) ) ? True : False;
t_5 = IsbPosObj( l_cached, Int_ObjInt(l_i) ) ? True : False;
t_3 = (Obj)(UInt)( ! EQ( t_4, t_5 ));
if ( t_3 ) {

Expand All @@ -1008,19 +1008,19 @@ static Obj HdlrFunc7 (
/* fi */

/* if IsBound( parent![i] ) and IsBound( cached![i] ) and not IS_IDENTICAL_OBJ( parent![i], cached![i] ) then */
t_6 = IsbPosObj( a_parent, INT_INTOBJ(l_i) ) ? True : False;
t_6 = IsbPosObj( a_parent, Int_ObjInt(l_i) ) ? True : False;
t_5 = (Obj)(UInt)(t_6 != False);
t_4 = t_5;
if ( t_4 ) {
t_7 = IsbPosObj( l_cached, INT_INTOBJ(l_i) ) ? True : False;
t_7 = IsbPosObj( l_cached, Int_ObjInt(l_i) ) ? True : False;
t_6 = (Obj)(UInt)(t_7 != False);
t_4 = t_6;
}
t_3 = t_4;
if ( t_3 ) {
t_8 = GF_IS__IDENTICAL__OBJ;
t_9 = ElmPosObj( a_parent, INT_INTOBJ(l_i) );
t_10 = ElmPosObj( l_cached, INT_INTOBJ(l_i) );
t_9 = ElmPosObj( a_parent, Int_ObjInt(l_i) );
t_10 = ElmPosObj( l_cached, Int_ObjInt(l_i) );
if ( TNUM_OBJ( t_8 ) == T_FUNCTION ) {
t_7 = CALL_2ARGS( t_8, t_9, t_10 );
}
Expand Down Expand Up @@ -1179,7 +1179,7 @@ static Obj HdlrFunc7 (
l_i = t_1;

/* if IsBound( parent![i] ) and not IsBound( type[i] ) then */
t_5 = IsbPosObj( a_parent, INT_INTOBJ(l_i) ) ? True : False;
t_5 = IsbPosObj( a_parent, Int_ObjInt(l_i) ) ? True : False;
t_4 = (Obj)(UInt)(t_5 != False);
t_3 = t_4;
if ( t_3 ) {
Expand All @@ -1191,7 +1191,7 @@ static Obj HdlrFunc7 (
if ( t_3 ) {

/* type[i] := parent![i]; */
t_3 = ElmPosObj( a_parent, INT_INTOBJ(l_i) );
t_3 = ElmPosObj( a_parent, Int_ObjInt(l_i) );
C_ASS_LIST_FPL( l_type, l_i, t_3 )

}
Expand Down Expand Up @@ -1244,8 +1244,8 @@ static Obj HdlrFunc7 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -2446,8 +2446,8 @@ static Obj HdlrFunc20 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -2746,8 +2746,8 @@ static Obj HdlrFunc20 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,13 @@ static void Emit(const char * fmt, ...)
Pr("%d", INTG_CVAR(cvar), 0);
}
else if ( IS_TEMP_CVAR(cvar) ) {
Pr("INT_INTOBJ(t_%d)", TEMP_CVAR(cvar), 0);
Pr("Int_ObjInt(t_%d)", TEMP_CVAR(cvar), 0);
}
else if ( LVAR_CVAR(cvar) <= narg ) {
Emit( "INT_INTOBJ(a_%n)", NAME_LVAR( LVAR_CVAR(cvar) ) );
Emit( "Int_ObjInt(a_%n)", NAME_LVAR( LVAR_CVAR(cvar) ) );
}
else {
Emit( "INT_INTOBJ(l_%n)", NAME_LVAR( LVAR_CVAR(cvar) ) );
Emit( "Int_ObjInt(l_%n)", NAME_LVAR( LVAR_CVAR(cvar) ) );
}
}

Expand Down
36 changes: 18 additions & 18 deletions src/hpc/c_oper1.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ static Obj HdlrFunc2 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -425,8 +425,8 @@ static Obj HdlrFunc2 (
}
while ( 1 ) {
if ( t_7 ) {
if ( LEN_LIST(t_8) < INT_INTOBJ(t_5) ) break;
t_6 = ELMV0_LIST( t_8, INT_INTOBJ(t_5) );
if ( LEN_LIST(t_8) < Int_ObjInt(t_5) ) break;
t_6 = ELMV0_LIST( t_8, Int_ObjInt(t_5) );
t_5 = (Obj)(((UInt)t_5)+4);
if ( t_6 == 0 ) continue;
}
Expand Down Expand Up @@ -895,8 +895,8 @@ static Obj HdlrFunc3 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -2214,8 +2214,8 @@ static Obj HdlrFunc6 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -2535,8 +2535,8 @@ static Obj HdlrFunc6 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -3401,8 +3401,8 @@ static Obj HdlrFunc8 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -3634,8 +3634,8 @@ static Obj HdlrFunc7 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -4945,8 +4945,8 @@ static Obj HdlrFunc18 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down Expand Up @@ -5239,8 +5239,8 @@ static Obj HdlrFunc17 (
}
while ( 1 ) {
if ( t_3 ) {
if ( LEN_LIST(t_4) < INT_INTOBJ(t_1) ) break;
t_2 = ELMV0_LIST( t_4, INT_INTOBJ(t_1) );
if ( LEN_LIST(t_4) < Int_ObjInt(t_1) ) break;
t_2 = ELMV0_LIST( t_4, Int_ObjInt(t_1) );
t_1 = (Obj)(((UInt)t_1)+4);
if ( t_2 == 0 ) continue;
}
Expand Down
Loading

0 comments on commit c04054b

Please sign in to comment.