summaryrefslogtreecommitdiff
path: root/other/fun
diff options
context:
space:
mode:
authorMaxim Biro <nurupo.contributions@gmail.com>2014-02-09 00:59:03 -0500
committerMaxim Biro <nurupo.contributions@gmail.com>2014-02-09 02:01:04 -0500
commitecbceac3414bf851d166e8ce7dceaf1dae12bb08 (patch)
tree897b4adcb52ec6c88c24673bfb5855c0d5a3e427 /other/fun
parent5fad72b910fde1bf66fecf7728ac73354ab23a3b (diff)
Fixed memory leaks and removed repeated code
Diffstat (limited to 'other/fun')
-rw-r--r--other/fun/sign.c15
1 files changed, 2 insertions, 13 deletions
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
21unsigned 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
34int load_file(char *filename, char **result) 22int 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;