Commit ff85a1e
committed
nshlib/nsh_fscmds.c: Allocate a PATH_MAX sized buffer for unlink_recursive
This fixes heap corruption when deleting a folder containing other folders
or files. The issue appeared at commit 131d50a, which removed the
stack-based temporary buffer.
unlink_recursive requires that the path is provided in PATH_MAX sized
buffer. It concatenates sub-folder or file names to the same buffer.
nsh_getfullpath just allocates a buffer using strdup, so there is no room
for concatenating more data to it.
To keep the stack usage smaller, instead of reverting the breaking commit,
allocate the temporary buffer with lib_get_pathbuffer instead.
Signed-off-by: Jukka Laitinen <[email protected]>1 parent 3f6fc4b commit ff85a1e
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2233 | 2233 | | |
2234 | 2234 | | |
2235 | 2235 | | |
2236 | | - | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
2237 | 2240 | | |
2238 | 2241 | | |
2239 | 2242 | | |
| |||
0 commit comments