]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Move to a more efficient pid-table impl. Note that the
authorJim Jagielski <jim@apache.org>
Thu, 25 Oct 2007 12:25:27 +0000 (12:25 +0000)
committerJim Jagielski <jim@apache.org>
Thu, 25 Oct 2007 12:25:27 +0000 (12:25 +0000)
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.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@588214 13f79535-47bb-0310-9956-ffa450edef68

src/CHANGES
src/main/http_main.c

index ae1f411f0b77f84c7f76e2291cdb1ab8b32eae7f..875d71209e54f86238403ea57e43ad5c289a57a0 100644 (file)
@@ -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
 
index 315027cb80e2a17b47408f6fb34e9934637d02d1..5d575dc715e8bba4be6418dd8bbda1249a51d4dc 100644 (file)
@@ -362,7 +362,7 @@ scoreboard *ap_scoreboard_image = NULL;
 /*
  * 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 @@ API_VAR_EXPORT int ap_change_shmem_uid = 0;
  */
 
 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 show_compile_settings(void)
  */
 static void common_init(void)
 {
+    int i;
     INIT_SIGLIST()
 #ifdef AUX3
     (void) set42sig();
@@ -4395,7 +4404,10 @@ static void common_init(void)
     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