]> granicus.if.org Git - apache/commitdiff
Be more expliciti in our error messages if the tmpnam() call fails,
authorKen Coar <coar@apache.org>
Wed, 3 May 2000 10:32:45 +0000 (10:32 +0000)
committerKen Coar <coar@apache.org>
Wed, 3 May 2000 10:32:45 +0000 (10:32 +0000)
or we have trouble opening the filename it returns.

PR: Not a solution, but will help debug several

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85129 13f79535-47bb-0310-9956-ffa450edef68

support/htpasswd.c

index 6dd49b9561188408943c09021000c7a0475fc1bb..65eb53042d5ac34daba7ff56177008c365715bb7 100644 (file)
@@ -518,9 +518,17 @@ int main(int argc, char *argv[])
      * to add or update.  Let's do it..
      */
     tempfilename = tmpnam(NULL);
+    if ((tempfilename == NULL) || (strlen(tempfilename) == 0)) {
+       fprintf(stderr, "%s: unable to generate temporary filename\n",
+               argv[0]);
+       errno = ENOENT;
+       perror("tmpnam");
+       exit(ERR_FILEPERM);
+    }
     ftemp = fopen(tempfilename, "w+");
     if (ftemp == NULL) {
-       fprintf(stderr, "%s: unable to create temporary file\n", argv[0]);
+       fprintf(stderr, "%s: unable to create temporary file '%s'\n", argv[0],
+               tempfilename);
        perror("fopen");
        exit(ERR_FILEPERM);
     }