Return-Path: Delivered-To: apmail-new-httpd-archive@apache.org Received: (qmail 54867 invoked by uid 500); 3 Jun 2000 02:07:06 -0000 Mailing-List: contact new-httpd-help@apache.org; run by ezmlm Precedence: bulk X-No-Archive: yes Reply-To: new-httpd@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list new-httpd@apache.org Received: (qmail 54856 invoked from network); 3 Jun 2000 02:07:06 -0000 Date: Fri, 2 Jun 2000 22:07:01 -0400 Message-Id: <200006030207.WAA18432@k5.localdomain> X-Authentication-Warning: k5.localdomain: trawick set sender to trawickj@bellsouth.net using -f From: Jeff Trawick To: new-httpd@apache.org In-reply-to: (message from Greg Stein on Fri, 2 Jun 2000 17:45:36 -0700 (PDT)) Subject: Re: cvs commit: apache-2.0/src/lib/apr/locks/unix locks.c locks.h Reply-to: trawickj@bellsouth.net References: X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N > Date: Fri, 2 Jun 2000 17:45:36 -0700 (PDT) > From: Greg Stein > 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 #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...