vim-patch:9.0.1847: [security] potential oob write in do_addsub()

Problem:  potential oob write in do_addsub()
Solution: don't overflow buf2, check size in for loop()

889f6af371

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq 2023-09-03 09:14:45 +08:00
parent b55010a539
commit 15298e7926

View File

@ -4770,7 +4770,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
} }
} }
while (bits > 0) { while (bits > 0 && i < NUMBUFLEN - 1) {
buf2[i++] = ((n >> --bits) & 0x1) ? '1' : '0'; buf2[i++] = ((n >> --bits) & 0x1) ? '1' : '0';
} }