httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <trawi...@bellsouth.net>
Subject Re: cvs commit: apache-2.0/src/lib/apr/locks/unix locks.c locks.h
Date Sat, 03 Jun 2000 02:07:01 GMT
> Date: Fri, 2 Jun 2000 17:45:36 -0700 (PDT)
> From: Greg Stein <gstein@lyra.org>
> 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/

I think a patch like this would solve it:

(not tested, but that never stopped anybody from posting or committing
code :) )

(seriously, I don't mind testing it, but I imagine that Ryan is
playing with it now... Ryan, let me know if I should verify and
commit; Greg will certainly speak up if it is obviously FUBAR)

Index: src/lib/apr/locks/unix/crossproc.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/locks/unix/crossproc.c,v
retrieving revision 1.27
diff -u -r1.27 crossproc.c
--- crossproc.c	2000/04/14 15:58:30	1.27
+++ crossproc.c	2000/06/03 02:07:24
@@ -53,6 +53,7 @@
  */
 
 #include "locks.h"
+#include <stdlib.h>
 
 #if defined (USE_SYSVSEM_SERIALIZE)  
 
@@ -269,7 +270,13 @@
 
 ap_status_t ap_unix_create_inter_lock(ap_lock_t *new)
 {
-    new->interproc = open(new->fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
+    if (new->fname) {
+        new->interproc = open(new->fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
+    }
+    else {
+        new->fname = ap_pstrdup(new->cntxt, "/tmp/aprXXXXXX"); 
+        new->interproc = mkstemp(new->fname);
+    }
 
     if (new->interproc < 0) {
         lock_cleanup(new);
@@ -338,7 +345,13 @@
 
 ap_status_t ap_unix_create_inter_lock(ap_lock_t *new)
 {
-    new->interproc = open(new->fname, O_CREAT | O_WRONLY | O_EXCL, 0600);
+    if (new->fname) {
+        new->interproc = open(new->fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
+    }
+    else {
+        new->fname = ap_pstrdup(new->cntxt, "/tmp/aprXXXXXX"); 
+        new->interproc = mkstemp(new->fname);
+    }
 
     if (new->interproc < 0) {
         lock_cleanup(new);
Index: src/lib/apr/locks/unix/locks.c
===================================================================
RCS file: /cvs/apache/apache-2.0/src/lib/apr/locks/unix/locks.c,v
retrieving revision 1.32
diff -u -r1.32 locks.c
--- locks.c	2000/06/03 00:31:13	1.32
+++ locks.c	2000/06/03 02:07:24
@@ -73,12 +73,6 @@
         if (fname != NULL) {
             new->fname = ap_pstrdup(cont, fname);
         }
-        else {
-            char *filename = "/tmp/aprXXXXXX";
-            new->interproc = mkstemp(filename);
-            new->fname = ap_pstrdup(cont, filename); 
-            unlink(new->fname);
-	}
     }
 #endif
 



-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Mime
View raw message