check that data alignment is in range and a power of two
Otherwise, the alignment gets truncated to fit in char, so `align 256` is handled as no alignment requirement.
This commit is contained in:
parent
1b7770e271
commit
85827e2232
1 changed files with 3 additions and 0 deletions
3
parse.c
3
parse.c
|
@ -1091,6 +1091,9 @@ parsedat(void cb(Dat *), Lnk *lnk)
|
|||
if (t == Talign) {
|
||||
if (nextnl() != Tint)
|
||||
err("alignment expected");
|
||||
if (tokval.num <= 0 || tokval.num > CHAR_MAX
|
||||
|| (tokval.num & (tokval.num-1)) != 0)
|
||||
err("invalid alignment");
|
||||
lnk->align = tokval.num;
|
||||
t = nextnl();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue