diff options
author | zwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-06-13 00:33:42 +0000 |
---|---|---|
committer | zwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2009-06-13 00:33:42 +0000 |
commit | bb37adadab7e99ce139179c1cb8322a7e1e921cb (patch) | |
tree | d791f276fa1787415cdbf170637567ec97892244 /src/target | |
parent | 6f9aac189206328568866244f471b5f27bbb0c45 (diff) | |
download | openocd_libswd-bb37adadab7e99ce139179c1cb8322a7e1e921cb.tar.gz openocd_libswd-bb37adadab7e99ce139179c1cb8322a7e1e921cb.tar.bz2 openocd_libswd-bb37adadab7e99ce139179c1cb8322a7e1e921cb.tar.xz openocd_libswd-bb37adadab7e99ce139179c1cb8322a7e1e921cb.zip |
Improve handle_load_image_command argument parsing:
- Use parse_u32 to ensure base/min/max addresses parse properly.
git-svn-id: svn://svn.berlios.de/openocd/trunk@2232 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/target.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/target/target.c b/src/target/target.c index c2f479ad..523b6fa1 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2153,8 +2153,12 @@ static int handle_load_image_command(struct command_context_s *cmd_ctx, char *cm /* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */ if (argc >= 2) { + u32 addr; + retval = parse_u32(args[1], &addr); + if (ERROR_OK != retval) + return ERROR_COMMAND_SYNTAX_ERROR; + image.base_address = addr; image.base_address_set = 1; - image.base_address = strtoul(args[1], NULL, 0); } else { @@ -2166,11 +2170,17 @@ static int handle_load_image_command(struct command_context_s *cmd_ctx, char *cm if (argc>=4) { - min_address=strtoul(args[3], NULL, 0); + retval = parse_u32(args[3], &min_address); + if (ERROR_OK != retval) + return ERROR_COMMAND_SYNTAX_ERROR; } if (argc>=5) { - max_address=strtoul(args[4], NULL, 0)+min_address; + retval = parse_u32(args[4], &max_address); + if (ERROR_OK != retval) + return ERROR_COMMAND_SYNTAX_ERROR; + // use size (given) to find max (required) + max_address += min_address; } if (min_address>max_address) |