You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ji...@apache.org on 2007/10/25 14:25:28 UTC

svn commit: r588214 - in /httpd/httpd/branches/1.3.x/src: CHANGES main/http_main.c

Author: jim
Date: Thu Oct 25 05:25:27 2007
New Revision: 588214

URL: http://svn.apache.org/viewvc?rev=588214&view=rev
Log:
Move to a more efficient pid-table impl. Note that the
change in common_init() will mean that mod_ssl won't cleanly
patch, so before we release, we'll need to make sure they
are aware.

Modified:
    httpd/httpd/branches/1.3.x/src/CHANGES
    httpd/httpd/branches/1.3.x/src/main/http_main.c

Modified: httpd/httpd/branches/1.3.x/src/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/1.3.x/src/CHANGES?rev=588214&r1=588213&r2=588214&view=diff
==============================================================================
--- httpd/httpd/branches/1.3.x/src/CHANGES (original)
+++ httpd/httpd/branches/1.3.x/src/CHANGES Thu Oct 25 05:25:27 2007
@@ -1,5 +1,7 @@
 Changes with Apache 1.3.40
 
+  *) More efficient implementation of the CVE-2007-3304 PID table
+     patch. [Jim Jagielski, Jeff Trawick]
 
 Changes with Apache 1.3.39
 

Modified: httpd/httpd/branches/1.3.x/src/main/http_main.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/1.3.x/src/main/http_main.c?rev=588214&r1=588213&r2=588214&view=diff
==============================================================================
--- httpd/httpd/branches/1.3.x/src/main/http_main.c (original)
+++ httpd/httpd/branches/1.3.x/src/main/http_main.c Thu Oct 25 05:25:27 2007
@@ -362,7 +362,7 @@
 /*
  * Parent process local storage of child pids
  */
-static table *pid_table;
+static int pid_table[HARD_SERVER_LIMIT];
 
 /*
  * Pieces for managing the contents of the Server response header
@@ -384,26 +384,34 @@
  */
 
 static int in_pid_table(int pid) {
-    char apid[64];      /* WAY generous! */
-    const char *spid;
-    ap_snprintf(apid, sizeof(apid), "%d", pid);
-    spid = ap_table_get(pid_table, apid);
-    if (spid && spid[0] == '1' && spid[1] == '\0')
-        return 1;
-    else
-        return 0;
+    int i;
+    for (i = 0; i < HARD_SERVER_LIMIT; i++) {
+        if (pid_table[i] == pid) {
+            return 1;
+        }
+    }
+    return 0;
 }
 
 static void set_pid_table(int pid) {
-    char apid[64];
-    ap_snprintf(apid, sizeof(apid), "%d", pid);
-    ap_table_set(pid_table, apid, "1");
+    int i;
+    for (i = 0; i < HARD_SERVER_LIMIT; i++) {
+        if (pid_table[i] == 0) {
+            pid_table[i] = pid;
+            break;
+        }
+    }
+    /* NOTE: Error detection?? */
 }
 
 static void unset_pid_table(int pid) {
-    char apid[64];
-    ap_snprintf(apid, sizeof(apid), "%d", pid);
-    ap_table_unset(pid_table, apid);
+    int i;
+    for (i = 0; i < HARD_SERVER_LIMIT; i++) {
+        if (pid_table[i] == pid) {
+            pid_table[i] = 0;
+            break;
+        }
+    }
 }
 
 /*
@@ -4370,6 +4378,7 @@
  */
 static void common_init(void)
 {
+    int i;
     INIT_SIGLIST()
 #ifdef AUX3
     (void) set42sig();
@@ -4395,7 +4404,10 @@
     ap_server_pre_read_config  = ap_make_array(pcommands, 1, sizeof(char *));
     ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
     ap_server_config_defines   = ap_make_array(pcommands, 1, sizeof(char *));
-    pid_table                  = ap_make_table(pglobal, HARD_SERVER_LIMIT);
+    /* overkill since static */
+    for (i = 0; i < HARD_SERVER_LIMIT; i++) {
+        pid_table[i] = 0;
+    }
 }
 
 #ifndef MULTITHREAD