aboutsummaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2014-08-08 18:40:57 +0200
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>2014-08-12 21:04:27 +0000
commit1fa24ebe399bb064f5d68311e712432b64327472 (patch)
tree79b68325cb4cea9bf70e8c389caf15e9bc3112cb /src/helper
parent5587013ad6f29ac309ac08e645927fa60d8f9332 (diff)
downloadriscv-openocd-1fa24ebe399bb064f5d68311e712432b64327472.zip
riscv-openocd-1fa24ebe399bb064f5d68311e712432b64327472.tar.gz
riscv-openocd-1fa24ebe399bb064f5d68311e712432b64327472.tar.bz2
Removed limit on lenght of command line options.
In particular -f and -s options may contains paths that can easily exceed the (old) 128 bytes buffer. Change-Id: Ifc198536549f50663e8e588519bb9ef75dcd172c Signed-off-by: Cristian Maglie <c.maglie@bug.st> Reviewed-on: http://openocd.zylin.com/2241 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/options.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/helper/options.c b/src/helper/options.c
index a378131..5351e82 100644
--- a/src/helper/options.c
+++ b/src/helper/options.c
@@ -141,7 +141,6 @@ static void add_default_dirs(void)
int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[])
{
int c;
- char command_buffer[128];
while (1) {
/* getopt_long stores the option index here. */
@@ -164,24 +163,26 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[])
break;
case 'f': /* --file | -f */
{
- snprintf(command_buffer, 128, "script {%s}", optarg);
- add_config_command(command_buffer);
+ char *command = alloc_printf("script {%s}", optarg);
+ add_config_command(command);
+ free(command);
break;
}
case 's': /* --search | -s */
add_script_search_dir(optarg);
break;
case 'd': /* --debug | -d */
- if (optarg)
- snprintf(command_buffer, 128, "debug_level %s", optarg);
- else
- snprintf(command_buffer, 128, "debug_level 3");
- command_run_line(cmd_ctx, command_buffer);
+ {
+ char *command = alloc_printf("debug_level %s", optarg ? optarg : "3");
+ command_run_line(cmd_ctx, command);
+ free(command);
break;
+ }
case 'l': /* --log_output | -l */
if (optarg) {
- snprintf(command_buffer, 128, "log_output %s", optarg);
- command_run_line(cmd_ctx, command_buffer);
+ char *command = alloc_printf("log_output %s", optarg);
+ command_run_line(cmd_ctx, command);
+ free(command);
}
break;
case 'c': /* --command | -c */