You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Roy Fielding <fi...@hyperreal.com> on 1997/02/10 10:40:35 UTC

cvs commit: apache/src http_core.c mod_asis.c

fielding    97/02/10 01:40:35

  Modified:    src       http_core.c mod_asis.c
  Log:
  Avoid fd leaks by using pfopen/pfclose instead of fopen/fclose.
  All the other uses of fopen/fclose, mostly for reading config files,
  are okay.
  
  Submitted by: Randy Terbush and Roy Fielding
  Reviewed by: Dean Gaudet, Jim Jagielski, Marc Slemko, Chuck Murcko
  
  Revision  Changes    Path
  1.65      +3 -3      apache/src/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/http_core.c,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -C3 -r1.64 -r1.65
  *** http_core.c	1997/02/03 02:42:57	1.64
  --- http_core.c	1997/02/10 09:40:33	1.65
  ***************
  *** 1288,1296 ****
        
    #ifdef __EMX__
        /* Need binary mode for OS/2 */
  !     f = fopen (r->filename, "rb");
    #else
  !     f = fopen (r->filename, "r");
    #endif
    
        if (f == NULL) {
  --- 1288,1296 ----
        
    #ifdef __EMX__
        /* Need binary mode for OS/2 */
  !     f = pfopen (r->pool, r->filename, "rb");
    #else
  !     f = pfopen (r->pool, r->filename, "r");
    #endif
    
        if (f == NULL) {
  ***************
  *** 1319,1325 ****
    	}
        }
    
  !     fclose(f);
        return OK;
    }
    
  --- 1319,1325 ----
    	}
        }
    
  !     pfclose(r->pool, f);
        return OK;
    }
    
  
  
  
  1.11      +5 -2      apache/src/mod_asis.c
  
  Index: mod_asis.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/mod_asis.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -C3 -r1.10 -r1.11
  *** mod_asis.c	1997/01/01 18:10:26	1.10
  --- mod_asis.c	1997/02/10 09:40:33	1.11
  ***************
  *** 69,75 ****
    	return NOT_FOUND;
        }
    	
  !     f = fopen (r->filename, "r");
    
        if (f == NULL) {
            log_reason("file permissions deny server access", r->filename, r);
  --- 69,75 ----
    	return NOT_FOUND;
        }
    	
  !     f = pfopen (r->pool, r->filename, "r");
    
        if (f == NULL) {
            log_reason("file permissions deny server access", r->filename, r);
  ***************
  *** 82,87 ****
  --- 82,89 ----
        if (location && location[0] == '/' && 
            ((r->status == HTTP_OK) || is_HTTP_REDIRECT(r->status))) {
    
  +         pfclose(r->pool, f);
  + 
            /* Internal redirect -- fake-up a pseudo-request */
            r->status = HTTP_OK;
    
  ***************
  *** 98,104 ****
        soft_timeout ("send", r);
        send_http_header (r);
        if (!r->header_only) send_fd (f, r);
  !     fclose (f);
        return OK;
    }
    
  --- 100,107 ----
        soft_timeout ("send", r);
        send_http_header (r);
        if (!r->header_only) send_fd (f, r);
  ! 
  !     pfclose(r->pool, f);
        return OK;
    }