From fc1c3e58ac7a2179cd32053ed63c4485edf543b6 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 7 Aug 2009 13:26:28 +0200 Subject: ensure vty code uses talloc_strdup() rather than regular strdup --- openbsc/src/vty/command.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'openbsc') diff --git a/openbsc/src/vty/command.c b/openbsc/src/vty/command.c index fa2114788..6173292a0 100644 --- a/openbsc/src/vty/command.c +++ b/openbsc/src/vty/command.c @@ -1803,16 +1803,9 @@ static char **cmd_complete_command_real(vector vline, struct vty *vty, descvec = vector_slot(strvec, index); for (j = 0; j < vector_active(descvec); j++) if ((desc = vector_slot(descvec, j))) { - if ((string = - cmd_entry_function - (vector_slot(vline, index), - desc->cmd))) - if (cmd_unique_string - (matchvec, string)) - vector_set - (matchvec, - strdup - (string)); + if ((string = cmd_entry_function(vector_slot(vline, index), desc->cmd))) + if (cmd_unique_string (matchvec, string)) + vector_set (matchvec, talloc_strdup(tall_vty_ctx, string)); } } } @@ -2661,7 +2654,7 @@ DEFUN(config_hostname, if (host.name) talloc_free(host.name); - host.name = strdup(argv[0]); + host.name = talloc_strdup(tall_vty_ctx, argv[0]); return CMD_SUCCESS; } @@ -2696,7 +2689,7 @@ DEFUN(config_password, password_cmd, host.password = NULL; if (host.password_encrypt) talloc_free(host.password_encrypt); - host.password_encrypt = strdup(strdup(argv[1])); + host.password_encrypt = talloc_strdup(tall_vty_ctx, argv[1]); return CMD_SUCCESS; } else { vty_out(vty, "Unknown encryption type.%s", VTY_NEWLINE); @@ -2719,10 +2712,10 @@ DEFUN(config_password, password_cmd, if (host.encrypt) { if (host.password_encrypt) talloc_free(host.password_encrypt); - host.password_encrypt = strdup(zencrypt(argv[0])); + host.password_encrypt = talloc_strdup(tall_vty_ctx, zencrypt(argv[0])); } else #endif - host.password = strdup(argv[0]); + host.password = talloc_strdup(tall_vty_ctx, argv[0]); return CMD_SUCCESS; } @@ -2755,7 +2748,7 @@ ALIAS(config_password, password_text_cmd, if (host.enable_encrypt) talloc_free(host.enable_encrypt); - host.enable_encrypt = strdup(argv[1]); + host.enable_encrypt = talloc_strdup(tall_vty_ctx, argv[1]); return CMD_SUCCESS; } else { @@ -2780,10 +2773,10 @@ ALIAS(config_password, password_text_cmd, if (host.encrypt) { if (host.enable_encrypt) talloc_free(host.enable_encrypt); - host.enable_encrypt = strdup(zencrypt(argv[0])); + host.enable_encrypt = talloc_strdup(tall_vty_ctx, zencrypt(argv[0])); } else #endif - host.enable = strdup(argv[0]); + host.enable = talloc_strdup(tall_vty_ctx, argv[0]); return CMD_SUCCESS; } @@ -2827,12 +2820,12 @@ DEFUN(service_password_encrypt, if (host.password) { if (host.password_encrypt) talloc_free(host.password_encrypt); - host.password_encrypt = strdup(zencrypt(host.password)); + host.password_encrypt = talloc_strdup(tall_vty_ctx, zencrypt(host.password)); } if (host.enable) { if (host.enable_encrypt) talloc_free(host.enable_encrypt); - host.enable_encrypt = strdup(zencrypt(host.enable)); + host.enable_encrypt = talloc_strdup(tall_vty_ctx, zencrypt(host.enable)); } return CMD_SUCCESS; @@ -3106,7 +3099,7 @@ static int set_log_file(struct vty *vty, const char *fname, int loglevel) if (host.logfile) talloc_free(host.logfile); - host.logfile = strdup(fname); + host.logfile = talloc_strdup(tall_vty_ctx, fname); return CMD_SUCCESS; } @@ -3296,7 +3289,7 @@ DEFUN(banner_motd_file, { if (host.motdfile) talloc_free(host.motdfile); - host.motdfile = strdup(argv[0]); + host.motdfile = talloc_strdup(tall_vty_ctx, argv[0]); return CMD_SUCCESS; } @@ -3324,7 +3317,7 @@ DEFUN(no_banner_motd, /* Set config filename. Called from vty.c */ void host_config_set(char *filename) { - host.config = strdup(filename); + host.config = talloc_strdup(tall_vty_ctx, filename); } void install_default(enum node_type node) -- cgit v1.2.3