summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Lasseter <nathan.je.lasseter@googlemail.com>2012-06-05 21:07:23 +0100
committerNathan Lasseter <nathan.je.lasseter@googlemail.com>2012-06-05 21:07:23 +0100
commitbce6e5dfbeff23d6701b6fc4c159cefcfb0006ea (patch)
tree420ce23f56417c944f802c4fc266267bf3ec05dd
parenta969d8f041c54314d0f311df67919341c58038b5 (diff)
Changed system() to rename() and moved temp file to local dir
-rw-r--r--Makefile4
-rw-r--r--encrypt.c6
2 files changed, 4 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 72594d9..677ba6a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CFLAGS=-Wall -Wextra -O3
+CFLAGS=-Wall -Wextra
encrypt: encrypt.c
gcc ${CFLAGS} ${EFLAGS} -o $@ $^
@@ -7,7 +7,7 @@ install:
cp encrypt /usr/local/bin/encrypt
uninstall:
- rm /usr/local/bin/sc-encrypt
+ rm /usr/local/bin/encrypt
clean:
rm encrypt
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;
}