@@ -1390,10 +1390,12 @@ char * LSAPI_GetHeader_r( LSAPI_Request * pReq, int headerIndex )
1390
1390
off = pReq -> m_pHeaderIndex -> m_headerOff [ headerIndex ];
1391
1391
if ( !off )
1392
1392
return NULL ;
1393
- if ( * (pReq -> m_pHttpHeader + off +
1394
- pReq -> m_pHeaderIndex -> m_headerLen [ headerIndex ]) )
1395
- * ( pReq -> m_pHttpHeader + off +
1396
- pReq -> m_pHeaderIndex -> m_headerLen [ headerIndex ]) = 0 ;
1393
+ if ( * (pReq -> m_pHttpHeader + off
1394
+ + pReq -> m_pHeaderIndex -> m_headerLen [ headerIndex ]) )
1395
+ {
1396
+ * ( pReq -> m_pHttpHeader + off
1397
+ + pReq -> m_pHeaderIndex -> m_headerLen [ headerIndex ]) = 0 ;
1398
+ }
1397
1399
return pReq -> m_pHttpHeader + off ;
1398
1400
}
1399
1401
@@ -1830,12 +1832,21 @@ ssize_t LSAPI_Write_Stderr_r( LSAPI_Request * pReq, const char * pBuf, size_t le
1830
1832
static char * GetHeaderVar ( LSAPI_Request * pReq , const char * name )
1831
1833
{
1832
1834
int i ;
1835
+ char * pValue ;
1833
1836
for ( i = 0 ; i < H_TRANSFER_ENCODING ; ++ i )
1834
1837
{
1835
1838
if ( pReq -> m_pHeaderIndex -> m_headerOff [i ] )
1836
1839
{
1837
1840
if ( strcmp ( name , CGI_HEADERS [i ] ) == 0 )
1838
- return pReq -> m_pHttpHeader + pReq -> m_pHeaderIndex -> m_headerOff [i ];
1841
+ {
1842
+ pValue = pReq -> m_pHttpHeader
1843
+ + pReq -> m_pHeaderIndex -> m_headerOff [i ];
1844
+ if ( * (pValue + pReq -> m_pHeaderIndex -> m_headerLen [i ]) != '\0' )
1845
+ {
1846
+ * (pValue + pReq -> m_pHeaderIndex -> m_headerLen [i ]) = '\0' ;
1847
+ }
1848
+ return pValue ;
1849
+ }
1839
1850
}
1840
1851
}
1841
1852
if ( pReq -> m_pHeader -> m_cntUnknownHeaders > 0 )
@@ -1862,7 +1873,15 @@ static char * GetHeaderVar( LSAPI_Request * pReq, const char * name )
1862
1873
++ p ; ++ pKey ;
1863
1874
}
1864
1875
if (( pKey == pKeyEnd )&& (!* p ))
1865
- return pReq -> m_pHttpHeader + pCur -> valueOff ;
1876
+ {
1877
+ pValue = pReq -> m_pHttpHeader + pCur -> valueOff ;
1878
+
1879
+ if ( * (pValue + pCur -> valueLen ) != '\0' )
1880
+ {
1881
+ * (pValue + pCur -> valueLen ) = '\0' ;
1882
+ }
1883
+ return pValue ;
1884
+ }
1866
1885
++ pCur ;
1867
1886
}
1868
1887
}
0 commit comments