From bce6e5dfbeff23d6701b6fc4c159cefcfb0006ea Mon Sep 17 00:00:00 2001 From: Nathan Lasseter Date: Tue, 5 Jun 2012 21:07:23 +0100 Subject: Changed system() to rename() and moved temp file to local dir --- encrypt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'encrypt.c') diff --git a/encrypt.c b/encrypt.c index b19015e..056d0da 100644 --- a/encrypt.c +++ b/encrypt.c @@ -25,7 +25,7 @@ int main(int argc, char** argv) { } while (strlen(passphrase) <= 0); // And a temporary file to hold the encrypted data - char tpath[] = "/tmp/SimCr.XXXXXX"; + char tpath[] = "SimCr.XXXXXX"; int tempfd = mkstemp(tpath); FILE* temp = fdopen(tempfd, "w"); @@ -48,9 +48,7 @@ int main(int argc, char** argv) { fclose(file); // Move the file back - char *cmd = malloc(strlen(tpath) + strlen(argv[1]) + 11); - sprintf(cmd, "%s %s %s", "/bin/mv", tpath, argv[1]); - if (system(cmd) != 0) { + if (rename(tpath, argv[1]) != 0) { fprintf(stderr, "Your encrypted file is located in %s.", tpath); return EXIT_FAILURE; } -- cgit v1.2.1