Commit 4282c9e6 authored by Daniel Salzman's avatar Daniel Salzman

knotc,knsupdate: fix overriden tsig key memory leak

parent 44b106e0
...@@ -351,6 +351,7 @@ int main(int argc, char **argv) ...@@ -351,6 +351,7 @@ int main(int argc, char **argv)
r_port = atoi(optarg); r_port = atoi(optarg);
break; break;
case 'y': case 'y':
knot_tsig_key_deinit(&params->r_key);
if (knot_tsig_key_init_str(&r_key, optarg) != KNOT_EOK) { if (knot_tsig_key_init_str(&r_key, optarg) != KNOT_EOK) {
rc = 1; rc = 1;
log_error("failed to parse TSIG key '%s'", optarg); log_error("failed to parse TSIG key '%s'", optarg);
...@@ -358,6 +359,7 @@ int main(int argc, char **argv) ...@@ -358,6 +359,7 @@ int main(int argc, char **argv)
} }
break; break;
case 'k': case 'k':
knot_tsig_key_deinit(&params->r_key);
if (knot_tsig_key_init_file(&r_key, optarg) != KNOT_EOK) { if (knot_tsig_key_init_file(&r_key, optarg) != KNOT_EOK) {
rc = 1; rc = 1;
log_error("failed to parse TSIG key file '%s'", optarg); log_error("failed to parse TSIG key file '%s'", optarg);
......
...@@ -234,10 +234,12 @@ int knsupdate_parse(knsupdate_params_t *params, int argc, char *argv[]) ...@@ -234,10 +234,12 @@ int knsupdate_parse(knsupdate_params_t *params, int argc, char *argv[])
if (ret != KNOT_EOK) return ret; if (ret != KNOT_EOK) return ret;
break; break;
case 'y': case 'y':
knot_tsig_key_deinit(&params->tsig_key);
ret = knot_tsig_key_init_str(&params->tsig_key, optarg); ret = knot_tsig_key_init_str(&params->tsig_key, optarg);
if (ret != KNOT_EOK) return ret; if (ret != KNOT_EOK) return ret;
break; break;
case 'k': case 'k':
knot_tsig_key_deinit(&params->tsig_key);
ret = knot_tsig_key_init_file(&params->tsig_key, optarg); ret = knot_tsig_key_init_file(&params->tsig_key, optarg);
if (ret != KNOT_EOK) return ret; if (ret != KNOT_EOK) return ret;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment