httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@gonzo.ben.algroup.co.uk>
Subject Re: cvs commit: apache/src alloc.c
Date Tue, 01 Oct 1996 08:20:32 GMT
Brian Behlendorf wrote:
> 
> brian       96/09/30 20:24:06
> 
>   Modified:    src       alloc.c
>   Log:
>   Reviewed by:	Brian Behlendorf
>   Submitted by:	Mark Brown, mbrown@openmarket.com
>   
>   On Tue, 24 Sep 1996, Mark Brown wrote:
>   > Here is a patch for the error log overwrite problem I reported
>   > earlier.  I have tested the patch on SunOS 4.1.4.
>   >
>   > The patch should have no ill effect on correct systems.
>   
>   Revision  Changes    Path
>   1.13      +16 -2     apache/src/alloc.c
>   
>   Index: alloc.c
>   ===================================================================
>   RCS file: /export/home/cvs/apache/src/alloc.c,v
>   retrieving revision 1.12
>   retrieving revision 1.13
>   diff -C3 -r1.12 -r1.13
>   *** alloc.c	1996/09/13 00:24:51	1.12
>   --- alloc.c	1996/10/01 03:24:04	1.13
>   ***************
>   *** 50,56 ****
>      *
>      */
>     
>   ! /* $Id: alloc.c,v 1.12 1996/09/13 00:24:51 jim Exp $ */
>     
>     
>     /*
>   --- 50,56 ----
>      *
>      */
>     
>   ! /* $Id: alloc.c,v 1.13 1996/10/01 03:24:04 brian Exp $ */
>     
>     
>     /*
>   ***************
>   *** 773,781 ****
>     
>     FILE *pfopen(struct pool *a, char *name, char *mode)
>     {
>   !   FILE *fd;
>     
>       block_alarms();
>       fd = fopen(name, mode);
>       if (fd != NULL) note_cleanups_for_file (a, fd);
>       unblock_alarms();
>   --- 773,795 ----
>     
>     FILE *pfopen(struct pool *a, char *name, char *mode)
>     {
>   !   FILE *fd = NULL;
>   !   int baseFlag, desc;
>     
>       block_alarms();
>   + 
>   +   if (*mode == 'a') {
>   +     /* Work around faulty implementations of fopen */
>   +     baseFlag = (*(mode+1) == '+') ? O_RDWR : O_WRONLY;
>   +     desc = open(name, baseFlag | O_APPEND | O_CREAT,
>   + 		S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
>   +     if (desc >= 0) {
>   +       fd = fdopen(desc, mode);
>   +     }
>   +   } else {
>   +     fd = fopen(name, mode);
>   +   }
>   + 
>       fd = fopen(name, mode);

Tch! This will open the file twice, the second time in the wrong mode. Besides,
the workaround should only apply to platforms that need it!

>       if (fd != NULL) note_cleanups_for_file (a, fd);
>       unblock_alarms();
>   
>   
>   

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant and    Fax:   +44 (181) 994 6472
Technical Director          Email: ben@algroup.co.uk
A.L. Digital Ltd,           URL: http://www.algroup.co.uk
London, England.            Apache Group member (http://www.apache.org)

Mime
View raw message