httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: httpd-2.0/server log.c mpm_common.c
Date Sat, 14 Aug 2004 10:49:44 GMT
trawick     2004/08/14 03:49:44

  Modified:    .        CHANGES
               server   log.c mpm_common.c
  Log:
  tweak error handling when reading the pid file
  
  previously strtol() would look at unitialized
  storage, but now the string is terminated where
  the data read ends
  
  give user a hint about removing the file if we can't
  read/parse it properly
  
  (somehow I ended up with a truncated httpd.pid on my
  own system, leading to these tweaks)
  
  Revision  Changes    Path
  1.1550    +2 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1549
  retrieving revision 1.1550
  diff -u -r1.1549 -r1.1550
  --- CHANGES	11 Aug 2004 21:14:49 -0000	1.1549
  +++ CHANGES	14 Aug 2004 10:49:43 -0000	1.1550
  @@ -2,6 +2,8 @@
   
     [Remove entries to the current 2.0 section below, when backported]
   
  +  *) Improve error handling for corrupted pid files.  [Jeff Trawick]
  +
     *) mod_proxy.c and proxy_util.c: Enable compiling on 2.0-HEAD 
        (for backwards compatibility):
        Avoids mod_ssl.h (not included in 2.0-HEAD) and
  
  
  
  1.149     +2 -3      httpd-2.0/server/log.c
  
  Index: log.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/log.c,v
  retrieving revision 1.148
  retrieving revision 1.149
  diff -u -r1.148 -r1.149
  --- log.c	11 Aug 2004 14:25:30 -0000	1.148
  +++ log.c	14 Aug 2004 10:49:43 -0000	1.149
  @@ -672,9 +672,7 @@
           return rv;
       }
   
  -    /* Ensure null-termination, so that strtol doesn't go crazy. */
       buf = apr_palloc(p, BUFFER_SIZE);
  -    buf[BUFFER_SIZE - 1] = '\0';
   
       rv = apr_file_read_full(pid_file, buf, BUFFER_SIZE - 1, &bytes_read);
       if (rv != APR_SUCCESS && rv != APR_EOF) {
  @@ -683,10 +681,11 @@
   
       /* If we fill the buffer, we're probably reading a corrupt pid file.
        * To be nice, let's also ensure the first char is a digit. */
  -    if (bytes_read == BUFFER_SIZE - 1 || !apr_isdigit(*buf)) {
  +    if (bytes_read == 0 || bytes_read == BUFFER_SIZE - 1 || !apr_isdigit(*buf)) {
           return APR_EGENERAL;
       }
   
  +    buf[bytes_read] = '\0';
       *mypid = strtol(buf, &endptr, 10);
   
       apr_file_close(pid_file);
  
  
  
  1.121     +2 -0      httpd-2.0/server/mpm_common.c
  
  Index: mpm_common.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/mpm_common.c,v
  retrieving revision 1.120
  retrieving revision 1.121
  diff -u -r1.120 -r1.121
  --- mpm_common.c	15 Mar 2004 23:08:41 -0000	1.120
  +++ mpm_common.c	14 Aug 2004 10:49:43 -0000	1.121
  @@ -728,6 +728,8 @@
           if (rv != APR_ENOENT) {
               ap_log_error(APLOG_MARK, APLOG_STARTUP, rv, NULL,
                            "Error retrieving pid file %s", ap_pid_fname);
  +            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
  +                         "Remove it before continuing if it is corrupted.");
               *exit_status = 1;
               return 1;
           }
  
  
  

Mime
View raw message