com php-src: Fixed a bug that header value is not terminated by '\0' when accessed through getenv().: sapi/litespeed/lsapilib.c
| From: | George Wang | Date: | Wed, 25 Feb 2015 16:24:19 +0000 |
| Subject: | com php-src: Fixed a bug that header value is not terminated by '\0' when accessed through getenv().: sapi/litespeed/lsapilib.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85087@lists.php.net to get a copy of this message | ||
Commit: 65810bf2596f3d03ec7baf0c5de01235c8ee7e35
Author: George Wang <gwang@php.net> Wed, 25 Feb 2015 10:48:19 -0500
Parents: 9502d67a8e7e13eb040d41ecc8f545ae1c7b2d14
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=65810bf2596f3d03ec7baf0c5de01235c8ee7e35
Log:
Fixed a bug that header value is not terminated by '\0' when accessed through getenv().
Changed paths:
M sapi/litespeed/lsapilib.c
Diff:
diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c
index cfd2503..fd94ee9 100644
--- a/sapi/litespeed/lsapilib.c
+++ b/sapi/litespeed/lsapilib.c
@@ -1390,10 +1390,12 @@ char * LSAPI_GetHeader_r( LSAPI_Request * pReq, int headerIndex )
off = pReq->m_pHeaderIndex->m_headerOff[ headerIndex ];
if ( !off )
return NULL;
- if ( *(pReq->m_pHttpHeader + off +
- pReq->m_pHeaderIndex->m_headerLen[ headerIndex ]) )
- *( pReq->m_pHttpHeader + off +
- pReq->m_pHeaderIndex->m_headerLen[ headerIndex ]) = 0;
+ if ( *(pReq->m_pHttpHeader + off
+ + pReq->m_pHeaderIndex->m_headerLen[ headerIndex ]) )
+ {
+ *( pReq->m_pHttpHeader + off
+ + pReq->m_pHeaderIndex->m_headerLen[ headerIndex ]) = 0;
+ }
return pReq->m_pHttpHeader + off;
}
@@ -1830,12 +1832,21 @@ ssize_t LSAPI_Write_Stderr_r( LSAPI_Request * pReq, const char * pBuf,
size_t le
static char * GetHeaderVar( LSAPI_Request * pReq, const char * name )
{
int i;
+ char * pValue;
for( i = 0; i < H_TRANSFER_ENCODING; ++i )
{
if ( pReq->m_pHeaderIndex->m_headerOff[i] )
{
if ( strcmp( name, CGI_HEADERS[i] ) == 0 )
- return pReq->m_pHttpHeader + pReq->m_pHeaderIndex->m_headerOff[i];
+ {
+ pValue = pReq->m_pHttpHeader
+ + pReq->m_pHeaderIndex->m_headerOff[i];
+ if ( *(pValue + pReq->m_pHeaderIndex->m_headerLen[i]) != '\0')
+ {
+ *(pValue + pReq->m_pHeaderIndex->m_headerLen[i]) = '\0';
+ }
+ return pValue;
+ }
}
}
if ( pReq->m_pHeader->m_cntUnknownHeaders > 0 )
@@ -1862,7 +1873,15 @@ static char * GetHeaderVar( LSAPI_Request * pReq, const char * name )
++p; ++pKey;
}
if (( pKey == pKeyEnd )&& (!*p ))
- return pReq->m_pHttpHeader + pCur->valueOff;
+ {
+ pValue = pReq->m_pHttpHeader + pCur->valueOff;
+
+ if ( *(pValue + pCur->valueLen) != '\0')
+ {
+ *(pValue + pCur->valueLen) = '\0';
+ }
+ return pValue;
+ }
++pCur;
}
}