string::find() result is a size_t, not an int
unwrap conditional return after error, or the output string will just be overwritten
This commit is contained in:
@@ -598,15 +598,17 @@ void ScreenPackages::HTTPUpdate()
|
|||||||
int HeaderEnd = m_sBUFFER.find("\n\n");
|
int HeaderEnd = m_sBUFFER.find("\n\n");
|
||||||
if( HeaderEnd == m_sBUFFER.npos )
|
if( HeaderEnd == m_sBUFFER.npos )
|
||||||
HeaderEnd = m_sBUFFER.find("\r\n\r\n");
|
HeaderEnd = m_sBUFFER.find("\r\n\r\n");
|
||||||
if( HeaderEnd != m_sBUFFER.npos )
|
if( HeaderEnd == m_sBUFFER.npos )
|
||||||
{
|
return;
|
||||||
int i = m_sBUFFER.find(" ");
|
|
||||||
int j = m_sBUFFER.find(" ",i+1);
|
size_t i = m_sBUFFER.find(" ");
|
||||||
int k = m_sBUFFER.find("\n",j+1);
|
size_t j = m_sBUFFER.find(" ",i+1);
|
||||||
|
size_t k = m_sBUFFER.find("\n",j+1);
|
||||||
if ( i == string::npos || j == string::npos || k == string::npos )
|
if ( i == string::npos || j == string::npos || k == string::npos )
|
||||||
{
|
{
|
||||||
m_iResponseCode = -100;
|
m_iResponseCode = -100;
|
||||||
m_sResponseName = "Malformed response.";
|
m_sResponseName = "Malformed response.";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
m_iResponseCode = atoi(m_sBUFFER.substr(i+1,j-i).c_str());
|
m_iResponseCode = atoi(m_sBUFFER.substr(i+1,j-i).c_str());
|
||||||
m_sResponseName = m_sBUFFER.substr( j+1, k-j).c_str();
|
m_sResponseName = m_sBUFFER.substr( j+1, k-j).c_str();
|
||||||
@@ -622,7 +624,6 @@ void ScreenPackages::HTTPUpdate()
|
|||||||
m_bGotHeader = true;
|
m_bGotHeader = true;
|
||||||
m_sBUFFER = m_sBUFFER.substr( HeaderEnd + 4 );
|
m_sBUFFER = m_sBUFFER.substr( HeaderEnd + 4 );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( m_bIsPackage )
|
if( m_bIsPackage )
|
||||||
|
|||||||
Reference in New Issue
Block a user