VirtualBox

Changeset 43136 in vbox for trunk/src/VBox/Main/webservice


Ignore:
Timestamp:
Aug 31, 2012 12:23:58 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
80508
Message:

Main/webservices: Raise SOAP FAULT in case of invalid string to Base64DecodeArray.

Location:
trunk/src/VBox/Main/webservice
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r42685 r43136  
    14371437    return aStr.c_str();
    14381438}
    1439 
    1440 void Base64DecodeByteArray(std::string& aStr, ComSafeArrayOut(BYTE, aData))
     1439#define DECODE_STR_MAX 0x100000
     1440void Base64DecodeByteArray(struct soap *soap, std::string& aStr, ComSafeArrayOut(BYTE, aData))
    14411441{
    14421442    const char* pszStr = aStr.c_str();
    14431443    ssize_t cbOut = RTBase64DecodedSize(pszStr, NULL);
    14441444
    1445     Assert(cbOut > 0);
     1445    if(cbOut > DECODE_STR_MAX)
     1446    {
     1447        WebLog("Decode string too long.\n");
     1448        RaiseSoapRuntimeFault(soap, VERR_BUFFER_OVERFLOW, (ComPtr<IUnknown>)NULL);
     1449    }
    14461450
    14471451    com::SafeArray<BYTE> result(cbOut);
    14481452    int rc = RTBase64Decode(pszStr, result.raw(), cbOut, NULL, NULL);
    1449     AssertRC(rc);
     1453    if (FAILED(rc))
     1454    {
     1455        WebLog("String Decoding Failed. ERROR: 0x%lX\n", rc);
     1456        RaiseSoapRuntimeFault(soap, rc, (ComPtr<IUnknown>)NULL);
     1457    }
    14501458
    14511459    result.detachTo(ComSafeArrayOutArg(aData));
  • trunk/src/VBox/Main/webservice/vboxweb.h

    r40151 r43136  
    9999std::string Base64EncodeByteArray(ComSafeArrayIn(BYTE, aData));
    100100
    101 void Base64DecodeByteArray(std::string& aStr, ComSafeArrayOut(BYTE, aData));
     101void Base64DecodeByteArray(struct soap *soap, std::string& aStr, ComSafeArrayOut(BYTE, aData));
    102102/****************************************************************************
    103103 *
  • trunk/src/VBox/Main/webservice/websrv-cpp.xsl

    r43103 r43136  
    547547       <xsl:value-of select="concat('com::SafeArray&lt;BYTE&gt; comcall_',$name, ';')" />
    548548       <xsl:call-template name="emitNewlineIndent8" />
    549        <xsl:value-of select="concat('Base64DecodeByteArray(',$structprefix,$name,', ComSafeArrayAsOutParam(comcall_',$name, '));')" />
     549       <xsl:value-of select="concat('Base64DecodeByteArray(soap, ',$structprefix,$name,', ComSafeArrayAsOutParam(comcall_',$name, '));')" />
    550550    </xsl:when>
    551551
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette