Closed kcwu closed 8 years ago
5632662 comes from file.c 5016
5016 width = REAL_WIDTH(i, h_env->limit - envs[h_env->envc].indent);
where i=-333330000
, width=333330000*79/100=5632662
.
I'm not familiar with html enough and don't know what is percentage larger than 100%. Maybe we should cap it to 100% ?
Fixed, thank you.
This bug is interesting since it triggered libgc's issue https://github.com/ivmai/bdwgc/issues/135 as well.
How to reproduce
gdb
This demonstrate libgc's bug. n+1 == -3413. libgc treat it as
unsigned long
== 18446744073709548203. The allocation should be failed (either return NULL or abort the program). But it returns 0x7df000.If continue to run
With further investigation, w3m's negative size comes from table.c, renderTable(), line 1733
where
max_width
=5632662 buttabwidth[0]
isshort
. After assignment,tabwidth[0]=-3434
found by afl-fuzz