projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix port number in pidfile.
[tinc]
/
src
/
tincctl.c
diff --git
a/src/tincctl.c
b/src/tincctl.c
index
bc64031
..
331299a
100644
(file)
--- a/
src/tincctl.c
+++ b/
src/tincctl.c
@@
-346,13
+346,13
@@
static FILE *ask_and_open(const char *filename, const char *what, const char *mo
them in.
*/
static bool ecdsa_keygen(bool ask) {
them in.
*/
static bool ecdsa_keygen(bool ask) {
- ecdsa_t key;
+ ecdsa_t
*
key;
FILE *f;
char *pubname, *privname;
fprintf(stderr, "Generating ECDSA keypair:\n");
FILE *f;
char *pubname, *privname;
fprintf(stderr, "Generating ECDSA keypair:\n");
- if(!
ecdsa_generate(&key
)) {
+ if(!
(key = ecdsa_generate()
)) {
fprintf(stderr, "Error during key generation!\n");
return false;
} else
fprintf(stderr, "Error during key generation!\n");
return false;
} else
@@
-370,7
+370,12
@@
static bool ecdsa_keygen(bool ask) {
fchmod(fileno(f), 0600);
#endif
fchmod(fileno(f), 0600);
#endif
- ecdsa_write_pem_private_key(&key, f);
+ if(!ecdsa_write_pem_private_key(key, f)) {
+ fprintf(stderr, "Error writing private key!\n");
+ ecdsa_free(key);
+ fclose(f);
+ return false;
+ }
fclose(f);
fclose(f);
@@
-385,11
+390,12
@@
static bool ecdsa_keygen(bool ask) {
if(!f)
return false;
if(!f)
return false;
- char *pubkey = ecdsa_get_base64_public_key(
&
key);
+ char *pubkey = ecdsa_get_base64_public_key(key);
fprintf(f, "ECDSAPublicKey = %s\n", pubkey);
free(pubkey);
fclose(f);
fprintf(f, "ECDSAPublicKey = %s\n", pubkey);
free(pubkey);
fclose(f);
+ ecdsa_free(key);
return true;
}
return true;
}
@@
-399,13
+405,13
@@
static bool ecdsa_keygen(bool ask) {
them in.
*/
static bool rsa_keygen(int bits, bool ask) {
them in.
*/
static bool rsa_keygen(int bits, bool ask) {
- rsa_t key;
+ rsa_t
*
key;
FILE *f;
char *pubname, *privname;
fprintf(stderr, "Generating %d bits keys:\n", bits);
FILE *f;
char *pubname, *privname;
fprintf(stderr, "Generating %d bits keys:\n", bits);
- if(!
rsa_generate(&key, bits, 0x10001
)) {
+ if(!
(key = rsa_generate(bits, 0x10001)
)) {
fprintf(stderr, "Error during key generation!\n");
return false;
} else
fprintf(stderr, "Error during key generation!\n");
return false;
} else
@@
-423,7
+429,12
@@
static bool rsa_keygen(int bits, bool ask) {
fchmod(fileno(f), 0600);
#endif
fchmod(fileno(f), 0600);
#endif
- rsa_write_pem_private_key(&key, f);
+ if(!rsa_write_pem_private_key(key, f)) {
+ fprintf(stderr, "Error writing private key!\n");
+ fclose(f);
+ rsa_free(key);
+ return false;
+ }
fclose(f);
fclose(f);
@@
-438,9
+449,15
@@
static bool rsa_keygen(int bits, bool ask) {
if(!f)
return false;
if(!f)
return false;
- rsa_write_pem_public_key(&key, f);
+ if(!rsa_write_pem_public_key(key, f)) {
+ fprintf(stderr, "Error writing public key!\n");
+ fclose(f);
+ rsa_free(key);
+ return false;
+ }
fclose(f);
fclose(f);
+ rsa_free(key);
return true;
}
return true;
}
@@
-775,7
+792,7
@@
static int cmd_start(int argc, char *argv[]) {
c = "tincd";
int nargc = 0;
c = "tincd";
int nargc = 0;
- char **nargv = x
malloc_and_zero
((optind + argc) * sizeof *nargv);
+ char **nargv = x
zalloc
((optind + argc) * sizeof *nargv);
nargv[nargc++] = c;
for(int i = 1; i < optind; i++)
nargv[nargc++] = c;
for(int i = 1; i < optind; i++)