You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Emanuel Norrbin (JIRA)" <ax...@ws.apache.org> on 2006/01/26 02:59:09 UTC

[jira] Created: (AXISCPP-923) Memory leak in HTTPChannel::ReportError

Memory leak in  HTTPChannel::ReportError
----------------------------------------

         Key: AXISCPP-923
         URL: http://issues.apache.org/jira/browse/AXISCPP-923
     Project: Axis-C++
        Type: Bug
  Components: Transport (axis3)  
    Versions: current (nightly)    
 Environment: All platforms, issue found in drop 24-Jan-2006 21:23 
    Reporter: Emanuel Norrbin


File: transport\axis3\HTTPChannel\HTTPChannel.cpp
Method:  void HTTPChannel::ReportError( char * szText1, char * szText2)
Line: 750 - 755

void HTTPChannel::ReportError( char * szText1, char * szText2)
{
    long        dwMsg = GETLASTERROR
    string *    sMsg = PLATFORM_GET_ERROR_MESSAGE( dwMsg);
    char        szMsg[600];

    sprintf( szMsg, "%s %d %s: '%s'\n", szText1, (int) dwMsg, szText2, sMsg->c_str());

    m_LastError = szMsg;
}

In this method the string* sMsg is never deleted. I don't see why a string* is used
when a string would have worked just as well, but if a pointer is used it has to be deleted.

/Emanuel



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-923) Memory leak in HTTPChannel::ReportError

Posted by "Henrik Nordberg (JIRA)" <ax...@ws.apache.org>.
    [ http://issues.apache.org/jira/browse/AXISCPP-923?page=comments#action_12364059 ] 

Henrik Nordberg commented on AXISCPP-923:
-----------------------------------------

I vote for changing the code to use string instead of string*. What was the thinking behind using a pointer in this case?

> Memory leak in  HTTPChannel::ReportError
> ----------------------------------------
>
>          Key: AXISCPP-923
>          URL: http://issues.apache.org/jira/browse/AXISCPP-923
>      Project: Axis-C++
>         Type: Bug
>   Components: Transport (axis3)
>     Versions: current (nightly)
>  Environment: All platforms, issue found in drop 24-Jan-2006 21:23 
>     Reporter: Emanuel Norrbin

>
> File: transport\axis3\HTTPChannel\HTTPChannel.cpp
> Method:  void HTTPChannel::ReportError( char * szText1, char * szText2)
> Line: 750 - 755
> void HTTPChannel::ReportError( char * szText1, char * szText2)
> {
>     long        dwMsg = GETLASTERROR
>     string *    sMsg = PLATFORM_GET_ERROR_MESSAGE( dwMsg);
>     char        szMsg[600];
>     sprintf( szMsg, "%s %d %s: '%s'\n", szText1, (int) dwMsg, szText2, sMsg->c_str());
>     m_LastError = szMsg;
> }
> In this method the string* sMsg is never deleted. I don't see why a string* is used
> when a string would have worked just as well, but if a pointer is used it has to be deleted.
> /Emanuel

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (AXISCPP-923) Memory leak in HTTPChannel::ReportError

Posted by "nadir amra (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-923?page=all ]

nadir amra reassigned AXISCPP-923:
----------------------------------

    Assignee: nadir amra

> Memory leak in  HTTPChannel::ReportError
> ----------------------------------------
>
>                 Key: AXISCPP-923
>                 URL: http://issues.apache.org/jira/browse/AXISCPP-923
>             Project: Axis-C++
>          Issue Type: Bug
>          Components: Transport (axis3)
>    Affects Versions: current (nightly)
>         Environment: All platforms, issue found in drop 24-Jan-2006 21:23 
>            Reporter: Emanuel Norrbin
>         Assigned To: nadir amra
>         Attachments: AXISCPP-923.patch
>
>
> File: transport\axis3\HTTPChannel\HTTPChannel.cpp
> Method:  void HTTPChannel::ReportError( char * szText1, char * szText2)
> Line: 750 - 755
> void HTTPChannel::ReportError( char * szText1, char * szText2)
> {
>     long        dwMsg = GETLASTERROR
>     string *    sMsg = PLATFORM_GET_ERROR_MESSAGE( dwMsg);
>     char        szMsg[600];
>     sprintf( szMsg, "%s %d %s: '%s'\n", szText1, (int) dwMsg, szText2, sMsg->c_str());
>     m_LastError = szMsg;
> }
> In this method the string* sMsg is never deleted. I don't see why a string* is used
> when a string would have worked just as well, but if a pointer is used it has to be deleted.
> /Emanuel

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org


[jira] Updated: (AXISCPP-923) Memory leak in HTTPChannel::ReportError

Posted by "Henrik Nordberg (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-923?page=all ]

Henrik Nordberg updated AXISCPP-923:
------------------------------------

    Attachment: AXISCPP-923.patch

This is a largish patch. The main fix is to change the PLATFORM_GET_ERROR_MESSAGE macro to return a string instead of a string*.
There were other issues in the code related to this. For example: in transport/axis3/HTTPSSLChannel/HTTPSSLChannel.cpp the old code looked like this:

char		fullMessage[600];
			sprintf( fullMessage,
					 "Failed to open connection to server: \n \
					 hostname='%s'\n\
					 port='%d'\n\
					 Error Message='%s'\
					 Error Code='%d'\n",
					 m_URL.getHostName(), m_URL.getPort(), message->c_str(), (int) dw);

which is a security problem since sprintf() can cause fullMessage to overflow. 
So I changed the error handling code in 9 places to look like this:

+			char pcErr[64], pcPort[64];
+			sprintf(pcErr,"%d",(int)dwError);
+			sprintf(pcPort,"%d",(int)m_URL.getPort());
+			string sMessage = PLATFORM_GET_ERROR_MESSAGE(dwError);
+			string sFullMessage =
+				"Failed to open connection to server: \n \
+				hostname='" + string(m_URL.getHostName()) + "'\n\
+				port='" + string(pcPort) + "'\n\
+				Error Message='" + sMessage + "'\
+				Error Code='" + string(pcErr) + "'\n";

I also had to apply the following const correctness fix:

-HTTPTransportException::HTTPTransportException(const int iExceptionCode, char* pcMessage):AxisException(iExceptionCode)
+HTTPTransportException::HTTPTransportException(const int iExceptionCode, const char* pcMessage):AxisException(iExceptionCode)

I have applied this patch on Linux and run all tests successfully.
This patch file was created on Windows using TortoiseSVN -> Create patch..., so the easiest way to apply it is probably using TortoiseSVN -> Apply patch...

 - Henrik


> Memory leak in  HTTPChannel::ReportError
> ----------------------------------------
>
>          Key: AXISCPP-923
>          URL: http://issues.apache.org/jira/browse/AXISCPP-923
>      Project: Axis-C++
>         Type: Bug
>   Components: Transport (axis3)
>     Versions: current (nightly)
>  Environment: All platforms, issue found in drop 24-Jan-2006 21:23 
>     Reporter: Emanuel Norrbin
>  Attachments: AXISCPP-923.patch
>
> File: transport\axis3\HTTPChannel\HTTPChannel.cpp
> Method:  void HTTPChannel::ReportError( char * szText1, char * szText2)
> Line: 750 - 755
> void HTTPChannel::ReportError( char * szText1, char * szText2)
> {
>     long        dwMsg = GETLASTERROR
>     string *    sMsg = PLATFORM_GET_ERROR_MESSAGE( dwMsg);
>     char        szMsg[600];
>     sprintf( szMsg, "%s %d %s: '%s'\n", szText1, (int) dwMsg, szText2, sMsg->c_str());
>     m_LastError = szMsg;
> }
> In this method the string* sMsg is never deleted. I don't see why a string* is used
> when a string would have worked just as well, but if a pointer is used it has to be deleted.
> /Emanuel

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-923) Memory leak in HTTPChannel::ReportError

Posted by "Emanuel Norrbin (JIRA)" <ax...@ws.apache.org>.
    [ http://issues.apache.org/jira/browse/AXISCPP-923?page=comments#action_12364131 ] 

Emanuel Norrbin commented on AXISCPP-923:
-----------------------------------------

This issue was reported on an old CVS drop but the issue still exists in svn revision 372576.
Using a string would be the best since m_LastError itself is a string, however there are many places
to change in the code. A simple fix for now would be to delete sMsg.

/Emanuel


> Memory leak in  HTTPChannel::ReportError
> ----------------------------------------
>
>          Key: AXISCPP-923
>          URL: http://issues.apache.org/jira/browse/AXISCPP-923
>      Project: Axis-C++
>         Type: Bug
>   Components: Transport (axis3)
>     Versions: current (nightly)
>  Environment: All platforms, issue found in drop 24-Jan-2006 21:23 
>     Reporter: Emanuel Norrbin

>
> File: transport\axis3\HTTPChannel\HTTPChannel.cpp
> Method:  void HTTPChannel::ReportError( char * szText1, char * szText2)
> Line: 750 - 755
> void HTTPChannel::ReportError( char * szText1, char * szText2)
> {
>     long        dwMsg = GETLASTERROR
>     string *    sMsg = PLATFORM_GET_ERROR_MESSAGE( dwMsg);
>     char        szMsg[600];
>     sprintf( szMsg, "%s %d %s: '%s'\n", szText1, (int) dwMsg, szText2, sMsg->c_str());
>     m_LastError = szMsg;
> }
> In this method the string* sMsg is never deleted. I don't see why a string* is used
> when a string would have worked just as well, but if a pointer is used it has to be deleted.
> /Emanuel

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (AXISCPP-923) Memory leak in HTTPChannel::ReportError

Posted by "nadir amra (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-923?page=all ]

nadir amra closed AXISCPP-923.
------------------------------

    Fix Version/s:  1.6 Beta
       Resolution: Fixed

> Memory leak in  HTTPChannel::ReportError
> ----------------------------------------
>
>                 Key: AXISCPP-923
>                 URL: http://issues.apache.org/jira/browse/AXISCPP-923
>             Project: Axis-C++
>          Issue Type: Bug
>          Components: Transport (axis3)
>    Affects Versions: current (nightly)
>         Environment: All platforms, issue found in drop 24-Jan-2006 21:23 
>            Reporter: Emanuel Norrbin
>         Assigned To: nadir amra
>             Fix For:  1.6 Beta
>
>         Attachments: AXISCPP-923.patch
>
>
> File: transport\axis3\HTTPChannel\HTTPChannel.cpp
> Method:  void HTTPChannel::ReportError( char * szText1, char * szText2)
> Line: 750 - 755
> void HTTPChannel::ReportError( char * szText1, char * szText2)
> {
>     long        dwMsg = GETLASTERROR
>     string *    sMsg = PLATFORM_GET_ERROR_MESSAGE( dwMsg);
>     char        szMsg[600];
>     sprintf( szMsg, "%s %d %s: '%s'\n", szText1, (int) dwMsg, szText2, sMsg->c_str());
>     m_LastError = szMsg;
> }
> In this method the string* sMsg is never deleted. I don't see why a string* is used
> when a string would have worked just as well, but if a pointer is used it has to be deleted.
> /Emanuel

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org