nshlib: guard nsh_getfullpath against NULL argv[1] in boot command - #3705
Merged
Conversation
A bare `boot` (no argument, argc == 1) passes argv[1] == NULL.
nsh_getfullpath(NULL) returns strdup(g_home) == "/" instead of NULL,
which turned the default-boot path (NULL -> board default image)
into "/". board_boot_image("/") then failed with -EINVAL (-22),
preventing the board from booting.
Guard the nsh_getfullpath() call so NULL passes through unchanged,
restoring the original default-boot behavior while still resolving
relative paths when an argument is given.
This fixes the regression introduced by the relative-path support
```
commit fabafbc (origin/master, origin/HEAD)
Author: Junbo Zheng <zhengjunbo1@xiaomi.com>
Date: Fri Jul 24 23:47:44 2026 +0800
nshlib: add relative image path support in boot command
cmd_boot passed the image path straight to boardctl(), which resolves
it in a context that does not inherit the NSH shell cwd, so relative
paths failed and only absolute paths worked. Use nsh_getfullpath() to
resolve relative paths against the cwd before calling boardctl().
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
```
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
xiaoxiang781216
approved these changes
Aug 7, 2026
cederom
approved these changes
Aug 7, 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
A bare
boot(no argument, argc == 1) passesargv[1] == NULL. nsh_getfullpath(NULL) returnsstrdup(g_home) == "/"nuttx-apps/nshlib/nsh_envcmds.c
Lines 191 to 203 in 6e61ce7
NULL, which turned the default-boot path (NULL -> board default image) into"/".board_boot_image("/")then failed with -EINVAL (-22), preventing the board from booting.Guard the
nsh_getfullpath()call so NULL passes through unchanged, restoring the original default-boot behavior while still resolving relative paths when an argument is given.This fixes the regression introduced by the relative-path support
Impact
Testing
Passed internal CT tests by running boot with no argument
-EINVALand no boot occurredSigned-off-by: Junbo Zheng zhengjunbo1@xiaomi.com