replace: Fix use of mktemp
authorSimo Sorce <idra@samba.org>
Wed, 25 Apr 2012 22:55:46 +0000 (18:55 -0400)
committerSimo Sorce <idra@samba.org>
Thu, 26 Apr 2012 14:14:24 +0000 (16:14 +0200)
mktemp always returns the template, so checking for NULL doesn't cactch any
error. Errors are reported by turning the template into an empty string.

Autobuild-User: Simo Sorce <idra@samba.org>
Autobuild-Date: Thu Apr 26 16:14:24 CEST 2012 on sn-devel-104

lib/replace/replace.c

index c076ba1fc8bee7c57d5a27dba901c53dce39d352..322bf49e91b9950fe682543fc5f275e88898daad 100644 (file)
@@ -412,8 +412,8 @@ int rep_mkstemp(char *template)
 {
        /* have a reasonable go at emulating it. Hope that
           the system mktemp() isn't completely hopeless */
 {
        /* have a reasonable go at emulating it. Hope that
           the system mktemp() isn't completely hopeless */
-       char *p = mktemp(template);
-       if (!p)
+       mktemp(template);
+       if (template[0] == 0)
                return -1;
        return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
 }
                return -1;
        return open(p, O_CREAT|O_EXCL|O_RDWR, 0600);
 }