FILE *r;
char *directory;
char line[PATH_MAX];
+ char abspath[PATH_MAX];
const char *fn;
/* Check stdin and stdout */
if(fn[0] != '/') {
#endif
/* The directory is a relative path or a filename. */
- char *p;
-
directory = get_current_dir_name();
- xasprintf(&p, "%s/%s", directory, fn);
+ snprintf(abspath, sizeof abspath, "%s/%s", directory, fn);
free(directory);
- fn = p;
+ fn = abspath;
}
umask(0077); /* Disallow everything for group and other */
BIGNUM *e = NULL;
RSA *rsa_key;
FILE *f;
- char *pubname, *privname;
+ char filename[PATH_MAX];
BN_GENCB *cb;
int result;
} else
fprintf(stderr, "Done.\n");
- xasprintf(&privname, "%s/rsa_key.priv", confbase);
- f = ask_and_open(privname, "private RSA key");
- free(privname);
+ snprintf(filename, sizeof filename, "%s/rsa_key.priv", confbase);
+ f = ask_and_open(filename, "private RSA key");
if(!f)
return false;
char *name = get_name();
if(name) {
- xasprintf(&pubname, "%s/hosts/%s", confbase, name);
+ snprintf(filename, sizeof filename, "%s/hosts/%s", confbase, name);
free(name);
} else {
- xasprintf(&pubname, "%s/rsa_key.pub", confbase);
+ snprintf(filename, sizeof filename, "%s/rsa_key.pub", confbase);
}
- f = ask_and_open(pubname, "public RSA key");
- free(pubname);
+ f = ask_and_open(filename, "public RSA key");
if(!f)
return false;