commit e67ceebfe8a9ab42a871a44455a052c9b07c9c71
parent 0855d3ce7110b7debf120d91c3b1d624315b3971
Author: Claudio Alessi <smoppy@gmail.com>
Date: Sat, 23 Apr 2016 20:27:23 +0200
Use mkstemp() in editbuf().
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/myadm.c b/myadm.c
@@ -288,7 +288,13 @@ ecalloc(size_t nmemb, size_t size) {
char *
editbuf(char *in, int len, int *sz) {
Arg a;
- char *tmp = "/tmp/myadm.tmp";
+ char tmp[] = "myadm.XXXXXX";
+ int fd;
+
+ fd = mkstemp(tmp);
+ if(fd == -1)
+ return NULL;
+ close(fd);
a.v = (const char*[]){"/bin/sh", "-c", "$EDITOR \"$0\"", tmp, NULL};
fput(tmp, in, len);