Repository navigation
nshlib/nsh_netcmds: check nsh_getfullpath return value for NULL - #4295
Merged
xiaoxiang781216 merged 1 commit intoDec 5, 2026
Merged
Conversation
xiaoxiang781216
approved these changes
Dec 4, 2026
In cmd_get(), cmd_put(), and cmd_wget(), check if nsh_getfullpath() returns NULL on allocation failure, report g_fmtcmdoutofmemory, free any allocated path strings, and return ERROR instead of passing NULL to tftpget(), tftpput(), or open(). Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Swatantra Yadav <maverickswatantra@gmail.com>
Swatantra-66
force-pushed
the
fix/nsh-netcmds-null-fullpath
branch
from
December 4, 2026 16:23
0f0b7cf to
9651b31
Compare
GUIDINGLI
approved these changes
Dec 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In nshlib/nsh_netcmds.c, cmd_get(), cmd_put(), and cmd_wget() call nsh_getfullpath() to resolve the local file path, but none of the three checked for a NULL return on allocation failure before passing fullpath to tftpget(), tftpput(), or open().
This patch checks if fullpath is NULL in all three commands, reports g_fmtcmdoutofmemory, frees any already-allocated path buffers (args.destpath in cmd_get()/cmd_put() and allocfile in cmd_wget()), and returns ERROR.
Impact
Prevents NULL pointer dereferences and path-buffer leaks in NSH network file-transfer commands when nsh_getfullpath() fails to allocate memory. No Kconfig, API, or host-tool changes.
Testing
Not tested at runtime with simulated OOM in nsh_getfullpath().