preproc: fix heap memory overflow CVE-2023-31722

paramlen has heap memory of length nparam+1. The value of variable i
may be greater than nparam+1, causing heap memory overflow. Therefore,
i and nparam+1 needs to be determined in the loop.

Fixes: https://bugzilla.nasm.us/show_bug.cgi?id=3392857#c1
Fixes: https://github.com/netwide-assembler/nasm/pull/83
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
hongjinghao 2023-09-05 20:28:26 +08:00 committed by H. Peter Anvin (Intel)
parent c651c28217
commit e39b856bde
2 changed files with 4 additions and 2 deletions

View file

@ -74,8 +74,10 @@ void *nasm_realloc(void *q, size_t size)
void nasm_free(void *q)
{
if (q)
if (q){
free(q);
q = NULL;
}
}
char *nasm_strdup(const char *s)