cvs: /php4 ChangeLog /php4/php4isapi php4isapi.c

From: Date: Wed, 04 Aug 1999 22:21:29 +0000
Subject: cvs: /php4 ChangeLog /php4/php4isapi php4isapi.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-3125@lists.php.net to get a copy of this message
zeev Wed Aug 4 18:21:29 1999 EDT Modified files: /php4 ChangeLog /php4/php4isapi php4isapi.c Log: * Fix bug #1963 * Support large ISAPI server variables Index: php4/ChangeLog diff -u php4/ChangeLog:1.35 php4/ChangeLog:1.36 --- php4/ChangeLog:1.35 Wed Aug 4 17:47:56 1999 +++ php4/ChangeLog Wed Aug 4 18:21:29 1999 @@ -2,6 +2,7 @@ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ??? ?? 1999, Version 4.0 Beta 2 +- Improved ISAPI module to supprt large server variables (Zeev) - Imported PHP3 fixes for problem with PHP as a dynamic module and Redhat libc2.1 in zlib module (Stefan) - Fixed sybase_fetch_object() (Zeev) Index: php4/php4isapi/php4isapi.c diff -u php4/php4isapi/php4isapi.c:1.23 php4/php4isapi/php4isapi.c:1.24 --- php4/php4isapi/php4isapi.c:1.23 Mon Aug 2 15:16:54 1999 +++ php4/php4isapi/php4isapi.c Wed Aug 4 18:21:29 1999 @@ -76,6 +76,15 @@ if (lpECB->GetServerVariable(lpECB->ConnID, *p, variable_buf, &variable_len) && variable_buf[0]) { php_info_print_table_row(2, *p, variable_buf); + } else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { + char *tmp_variable_buf; + + tmp_variable_buf = (char *) emalloc(variable_len); + if (lpECB->GetServerVariable(lpECB->ConnID, *p, tmp_variable_buf, &variable_len) + && variable_buf[0]) { + php_info_print_table_row(2, *p, tmp_variable_buf); + } + efree(tmp_variable_buf); } p++; } @@ -234,12 +243,21 @@ { LPEXTENSION_CONTROL_BLOCK lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); char variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; - DWORD variable_len; + DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; - if (!lpECB->GetServerVariable(lpECB->ConnID, "HTTP_COOKIE", variable_buf, &variable_len)) { - return NULL; + if (lpECB->GetServerVariable(lpECB->ConnID, "HTTP_COOKIE", variable_buf, &variable_len)) { + return estrndup(variable_buf, variable_len); + } else if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) { + char *tmp_variable_buf = (char *) emalloc(variable_len+1); + + if (lpECB->GetServerVariable(lpECB->ConnID, "HTTP_COOKIE", tmp_variable_buf, &variable_len)) { + tmp_variable_buf[variable_len] = 0; + return tmp_variable_buf; + } else { + efree(tmp_variable_buf); + } } - return estrndup(variable_buf, variable_len); + return NULL; } @@ -330,15 +348,26 @@ static void hash_isapi_variables(ELS_D SLS_DC) { - char variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; + char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE]; + char *variable_buf; DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE; char *variable; LPEXTENSION_CONTROL_BLOCK lpECB; lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context); - if (!lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", variable_buf, &variable_len)) { - return; + if (lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", static_variable_buf, &variable_len)) { + variable_buf = static_variable_buf; + } else { + if (GetLastError()==ERROR_INSUFFICIENT_BUFFER) { + variable_buf = (char *) emalloc(variable_len); + if (!lpECB->GetServerVariable(lpECB->ConnID, "ALL_HTTP", variable_buf, &variable_len)) { + efree(variable_buf); + return; + } + } else { + return; + } } variable = strtok(variable_buf, "\r\n"); while (variable) { @@ -360,6 +389,9 @@ *colon = ':'; } variable = strtok(NULL, "\r\n"); + } + if (variable_buf!=static_variable_buf) { + efree(variable_buf); } }

« previous php.version4 (#3125) next »