Skip to content

Commit

Permalink
lib: shell: replace strtol with strtoul in cmd_load for address parsing
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
jakub-uC authored and github-actions[bot] committed Nov 21, 2024
1 parent 8469084 commit fb8e86e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions subsys/shell/modules/devmem_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,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;
Expand Down

0 comments on commit fb8e86e

Please sign in to comment.