diff options
| author | Michael Forney <[email protected]> | 2024-03-26 11:04:42 -0700 |
|---|---|---|
| committer | Quentin Carbonneaux <[email protected]> | 2024-03-28 10:35:11 +0100 |
| commit | 85827e2232d65920ddc2d6323d9dea8f9de0cf89 (patch) | |
| tree | a5849faf238a207e4ea0731127681f0325868f66 /parse.c | |
| parent | 1b7770e271252cf01ec2e13b97c82922387e3e41 (diff) | |
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.
Diffstat (limited to 'parse.c')
| -rw-r--r-- | parse.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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(); } |
