httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Stein <gst...@lyra.org>
Subject Re: cvs commit: apache-2.0/src/lib/apr/locks/unix locks.c locks.h
Date Sat, 03 Jun 2000 00:45:36 GMT
On 3 Jun 2000 rbb@locus.apache.org wrote:
> rbb         00/06/02 17:31:15
> 
>   Modified:    src/lib/apr/locks/unix locks.c locks.h
>   Log:
>   FreeBSD 4.0 doesn't like tempnam, so we are using mkstemp now.  I hope
>   this works on all platforms, but if not we'll just use a #ifdef later.
>   
>   Revision  Changes    Path
>   1.32      +3 -1      apache-2.0/src/lib/apr/locks/unix/locks.c
>   
>   Index: locks.c
>   ===================================================================
>   RCS file: /home/cvs/apache-2.0/src/lib/apr/locks/unix/locks.c,v
>   retrieving revision 1.31
>   retrieving revision 1.32
>   diff -u -r1.31 -r1.32
>   --- locks.c	2000/04/30 21:17:56	1.31
>   +++ locks.c	2000/06/03 00:31:13	1.32
>   @@ -74,7 +74,9 @@
>                new->fname = ap_pstrdup(cont, fname);
>            }
>            else {
>   -            new->fname = ap_pstrdup(cont, tempnam(NULL, NULL));
>   +            char *filename = "/tmp/aprXXXXXX";
>   +            new->interproc = mkstemp(filename);
>   +            new->fname = ap_pstrdup(cont, filename); 
>                unlink(new->fname);

Two problems:

1) mkstemp() modifies its argument. The above code will segfault since
   "/tmp/aprXXXXXX" is constant string data.

   I changed the code to look like:

        else {
            new->fname = ap_pstrdup(cont, "/tmp/aprXXXXXX"); 
            new->interproc = mkstemp(new->fname);
            unlink(new->fname);
	}


2) mkstemp() opens the file, yet ap_unix_create_inter_lock() will open the
   file again (and fail, I presume)

   This part messed me up (not familiar enough with the code), so I didn't
   check in the above change.


Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/



Mime
View raw message