Commit 831a683
committed
cvtsudoers_make_grlist_item: fix heap overflow on reallocation
cvtsudoers_make_grlist_item() estimated the size of the buffer used
to store a group list item based on the system's maximum group
length. However, it is possible for the invoking user to specify
a group of arbitrary length. There is a check to avoid overflowing
the buffer if the estimate is too small, but that code path re-uses
the ngroups variable which has since been reset. This can result
in the resized buffer being too small, leading to an overflow.
Since we have the list of groups to be added, we can allocate the
needed amount instead of estimating it. This removes the need for
reallocation on overflow.
Reported by Bartlomiej Dmitruk1 parent b890d52 commit 831a683
1 file changed
Lines changed: 8 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
393 | | - | |
394 | 393 | | |
395 | 394 | | |
396 | 395 | | |
| |||
401 | 400 | | |
402 | 401 | | |
403 | 402 | | |
404 | | - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
405 | 408 | | |
406 | 409 | | |
| 410 | + | |
407 | 411 | | |
408 | 412 | | |
409 | 413 | | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | 414 | | |
417 | 415 | | |
418 | 416 | | |
| |||
451 | 449 | | |
452 | 450 | | |
453 | 451 | | |
454 | | - | |
| 452 | + | |
455 | 453 | | |
456 | | - | |
| 454 | + | |
457 | 455 | | |
458 | 456 | | |
459 | 457 | | |
| |||
0 commit comments