Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport v3.7-branch] lib: shell: replace strtol with strtoul in cmd_load for address parsing #81696

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
lib: shell: replace strtol with strtoul in cmd_load for address parsing
Addresses in cmd_load() should always be unsigned. Previously, strtol()
was used, which is limited to signed long values, causing issues with
addresses >= 0x80000000. This commit replaces strtol() with strtoul(),
ensuring proper handling of the full 32-bit address space.

Fixes #81343

Signed-off-by: Aaron Fontaine <[email protected]>
Signed-off-by: Jakub Rzeszutko <[email protected]>
(cherry picked from commit 1aaf08f)
jakub-uC authored and github-actions[bot] committed Nov 21, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d6b571b2d263b42da39895b31505182cd1f96c8e
4 changes: 2 additions & 2 deletions subsys/shell/modules/devmem_service.c
Original file line number Diff line number Diff line change
@@ -250,8 +250,8 @@ static int cmd_load(const struct shell *sh, size_t argc, char **argv)
argc--;
}

bytes = (unsigned char *)strtol(argv[1], NULL, 0);
data = (uint32_t *)strtol(argv[1], NULL, 0);
bytes = (unsigned char *)strtoul(argv[1], NULL, 0);
data = (uint32_t *)strtoul(argv[1], NULL, 0);

set_bypass(sh, bypass_cb);
return 0;