diff options
author | irungentoo <irungentoo@tox.im> | 2014-02-09 09:27:50 -0500 |
---|---|---|
committer | irungentoo <irungentoo@tox.im> | 2014-02-09 09:27:50 -0500 |
commit | c498c206ed8eb2bd24031ddbe10956ff8bc9a82d (patch) | |
tree | ca7ff20c531951eea055a93f7a9a7ad274fa57e5 /other | |
parent | 7f977f9ad2fd4fdbfc1aec2081909da38cf601e9 (diff) | |
parent | 3782213b6e2731a29110e940546aa8981efad08b (diff) |
Merge pull request #720 from nurupo/master
Fixed some memory leaks
Diffstat (limited to 'other')
-rw-r--r-- | other/bootstrap_serverdaemon/tox_bootstrap_daemon.c | 5 | ||||
-rw-r--r-- | other/fun/sign.c | 15 |
2 files changed, 5 insertions, 15 deletions
diff --git a/other/bootstrap_serverdaemon/tox_bootstrap_daemon.c b/other/bootstrap_serverdaemon/tox_bootstrap_daemon.c index f2c54bb1..7f1f652c 100644 --- a/other/bootstrap_serverdaemon/tox_bootstrap_daemon.c +++ b/other/bootstrap_serverdaemon/tox_bootstrap_daemon.c | |||
@@ -266,8 +266,9 @@ int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6) | |||
266 | goto next; | 266 | goto next; |
267 | } | 267 | } |
268 | 268 | ||
269 | const int address_resolved = DHT_bootstrap_from_address(dht, bs_address, enable_ipv6, htons(bs_port), | 269 | uint8_t *bs_public_key_bin = hex_string_to_bin((char *)bs_public_key); |
270 | hex_string_to_bin((char *)bs_public_key)); | 270 | const int address_resolved = DHT_bootstrap_from_address(dht, bs_address, enable_ipv6, htons(bs_port), bs_public_key_bin); |
271 | free(bs_public_key_bin); | ||
271 | 272 | ||
272 | if (!address_resolved) { | 273 | if (!address_resolved) { |
273 | syslog(LOG_WARNING, "Bootstrap server #%d: Invalid '%s': %s. Skipping the server.\n", i, NAME_ADDRESS, bs_address); | 274 | syslog(LOG_WARNING, "Bootstrap server #%d: Invalid '%s': %s. Skipping the server.\n", i, NAME_ADDRESS, bs_address); |
diff --git a/other/fun/sign.c b/other/fun/sign.c index 423d974a..eaea9d6a 100644 --- a/other/fun/sign.c +++ b/other/fun/sign.c | |||
@@ -17,19 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | #include <sodium.h> | 18 | #include <sodium.h> |
19 | #include <string.h> | 19 | #include <string.h> |
20 | 20 | #include "../../testing/misc_tools.c" // hex_string_to_bin | |
21 | unsigned char *hex_string_to_bin(char hex_string[]) | ||
22 | { | ||
23 | size_t len = strlen(hex_string); | ||
24 | unsigned char *val = malloc(len); | ||
25 | char *pos = hex_string; | ||
26 | int i; | ||
27 | |||
28 | for (i = 0; i < len; ++i, pos += 2) | ||
29 | sscanf(pos, "%2hhx", &val[i]); | ||
30 | |||
31 | return val; | ||
32 | } | ||
33 | 21 | ||
34 | int load_file(char *filename, char **result) | 22 | int load_file(char *filename, char **result) |
35 | { | 23 | { |
@@ -90,6 +78,7 @@ int main(int argc, char *argv[]) | |||
90 | unsigned long long smlen; | 78 | unsigned long long smlen; |
91 | char *sm = malloc(size + crypto_sign_ed25519_BYTES * 2); | 79 | char *sm = malloc(size + crypto_sign_ed25519_BYTES * 2); |
92 | crypto_sign_ed25519(sm, &smlen, data, size, secret_key); | 80 | crypto_sign_ed25519(sm, &smlen, data, size, secret_key); |
81 | free(secret_key); | ||
93 | 82 | ||
94 | if (smlen - size != crypto_sign_ed25519_BYTES) | 83 | if (smlen - size != crypto_sign_ed25519_BYTES) |
95 | goto fail; | 84 | goto fail; |