Open awen-li opened 3 years ago
from bounter import CountMinSketch
Cms = None LogCounting = None
def setUp(LogCounting = None): return CountMinSketch(1, width=2**31, depth=32, log_counting=LogCounting)
Cms = setUp () for i in range (0, 100): Cms.increment('foo') Cms.increment('bar')
Crash: Segmentation fault (core dumped)
@Daybreak2019 can you open a PR with a fix? Thanks!
FWIW, this seems to have had a CVE opened against it: https://nvd.nist.gov/vuln/detail/CVE-2021-41497
Description
In CMS_Conservative_init, w is received from Python code. Its size is not validated hence "self->table[i] = (CMS_CELL_TYPE *) calloc(self->width, sizeof(CMS_CELL_TYPE));" may fail , which cause the Null pointer. self->table[i] would be accessed in CMS_Conservative_increment_obj, which make the Python crash down.
Steps/Code/Corpus to Reproduce
Optional call-path: increment -> CMS_Log1024_increment -> CMS_Conservative_increment_obj
Expected Results
when w is set as an arbitrary number, Python can not crash down.
Actual Results
crash
Versions
the main branch