Commit 38d909a
cvtsudoers_make_gritem: fix off-by-one in gr_mem allocation
cvtsudoers_make_gritem() allocates space for the gr_mem pointer array
using sizeof(char *) * nmem, where nmem is the number of filter users.
However, gr_mem is a conventional NULL-terminated array, and the NULL
terminator slot was never included in the allocation. When
newgr->gr_mem[nmem] is subsequently written with NULL, it lands one
pointer past the end of the reserved pointer array, overwriting the
first bytes of the adjacent member-string data. With few members and
short names the write can extend past the end of the allocation
entirely, corrupting adjacent heap memory.
Fix by incrementing nmem before computing the pointer-array size, so
that the NULL terminator slot is included in the allocation. This
mirrors the pattern used in PREFIX(make_gritem) in pwutil_impl.c.1 parent e6a5c1c commit 38d909a
1 file changed
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
| |||
0 commit comments