]> diplodocus.org Git - nmh/commitdiff
Replaced use of mkstemp() with m_mktemp() in lock_file.c.
authorDavid Levine <levinedl@acm.org>
Sat, 25 Jan 2014 02:29:38 +0000 (20:29 -0600)
committerDavid Levine <levinedl@acm.org>
Sat, 25 Jan 2014 02:29:38 +0000 (20:29 -0600)
sbr/lock_file.c

index 01d7ae49a849e4710c46ca7942334dfc05d2de54..6a3be51924a6d4167665602c2b59b7b9e00cdfbe 100644 (file)
@@ -543,17 +543,18 @@ static int
 lockit (struct lockinfo *li)
 {
     int fd;
-    char *curlock, *tmplock;
+    char *curlock, *tmpfile;
 
 #if 0
     char buffer[128];
 #endif
 
     curlock = li->curlock;
-    tmplock = li->tmplock;
 
-    if ((fd = mkstemp(tmplock)) == -1)
+    if ((tmpfile = m_mktemp(li->tmplock, &fd, NULL)) == NULL) {
+        advise(NULL, "unable to create temporary file in %s", get_temp_dir());
        return -1;
+    }
 
 #if 0
     /* write our process id into lock file */
@@ -567,8 +568,8 @@ lockit (struct lockinfo *li)
      * Now try to create the real lock file
      * by linking to the temporary file.
      */
-    fd = link(tmplock, curlock);
-    unlink(tmplock);
+    fd = link(tmpfile, curlock);
+    unlink(tmpfile);
 
     return (fd == -1 ? -1 : 0);
 }