ndisasm: Stack buffer overflow fix

Changing the type of `to_read` from `uint32_t` to
`int32_t` makes it aware of negative numbers and fixes
the buffer overflow in ndisasm.

Signed-off-by: T Turek <tureqsec@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
turekt 2020-12-14 19:54:08 +00:00 committed by Cyrill Gorcunov
parent aa2dcdec09
commit a9faae3e0b

View file

@ -297,7 +297,7 @@ int main(int argc, char **argv)
p = q = buffer;
nextsync = next_sync(offset, &synclen);
do {
uint32_t to_read = buffer + sizeof(buffer) - p;
int32_t to_read = buffer + sizeof(buffer) - p;
if ((nextsync || synclen) &&
to_read > nextsync - offset - (p - q))
to_read = nextsync - offset - (p - q);