jim 98/12/03 06:38:06
Modified: src/modules/standard mod_status.c Log: Reduce a race condition... We doubly protect against a bogus vhostrec pointer. The first test sets the pointer correctly no matter what the value of vhostrec. When it's time to print out, we check again. If the previous value was NULL, then no matter what, "NULL" will be used for the hostname, even if the new vhostrec was changed between the 2 tests to be valid. If the previous was OK, then the vhost value will only be printed if it's still OK. There's still a window between this final test and when the actual string is printed, since it's possible (maybe) that right after the test, the vhostrec is no longer valid, but assuming that the memory hasn't been released or overwritten, we still point to a good string. Revision Changes Path 1.102 +6 -2 apache-1.3/src/modules/standard/mod_status.c Index: mod_status.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_status.c,v retrieving revision 1.101 retrieving revision 1.102 diff -u -r1.101 -r1.102 --- mod_status.c 1998/12/03 01:08:00 1.101 +++ mod_status.c 1998/12/03 14:38:05 1.102 @@ -254,6 +254,7 @@ char stat_buffer[HARD_SERVER_LIMIT]; int pid_buffer[HARD_SERVER_LIMIT]; clock_t tu, ts, tcu, tcs; + char *vhost; tu = ts = tcu = tcs = 0; @@ -308,6 +309,10 @@ for (i = 0; i < HARD_SERVER_LIMIT; ++i) { score_record = ap_scoreboard_image->servers[i]; ps_record = ap_scoreboard_image->parent[i]; + if (score_record.vhostrec) + vhost = score_record.vhostrec->server_hostname; + else + vhost = "NULL"; res = score_record.status; stat_buffer[i] = status_flags[res]; pid_buffer[i] = (int) ps_record.pid; @@ -653,8 +658,7 @@ ap_rprintf(r, "<td>%s<td nowrap>%s<td nowrap>%s</tr>\n\n", score_record.client, - (score_record.vhostrec ? - score_record.vhostrec->server_hostname : "NULL"), + (score_record.vhostrec ? vhost : "NULL"), ap_escape_html(r->pool, score_record.request)); } /* no_table_report */ } /* !short_report */