VirtualBox

Ignore:
Timestamp:
Oct 6, 2015 1:06:34 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
103103
Message:

uri.cpp: r=bird: You need to decode the stuff, you cannot just copy raw URI bytes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/uri.cpp

    r57983 r58049  
    122122{
    123123    AssertPtrReturn(pszString, NULL);
    124     AssertReturn(strlen(pszString) >= cchString, NULL);
     124    AssertReturn(memchr(pszString, '\0', cchString) == NULL, NULL);
    125125
    126126    /*
     
    797797         */
    798798        char *pszResult;
    799 
    800         do
    801         {
    802             char *pszTmp = pszResult = RTStrAlloc(cbResult);
    803             if (pszTmp)
     799        char *pszTmp = pszResult = RTStrAlloc(cbResult);
     800        if (pszTmp)
     801        {
     802            size_t cbTmp = cbResult;
     803            if (uFormat == URI_FILE_FORMAT_WIN)
    804804            {
    805                 size_t cbTmp = cbResult;
    806 
    807                 if (uFormat == URI_FILE_FORMAT_WIN)
     805                /* If an authority is given, add the required UNC prefix. */
     806                if (Parsed.cchAuthority)
    808807                {
    809                     /* If an authority is given, add the required UNC prefix. */
    810                     if (Parsed.cchAuthority)
    811                     {
    812                         rc = RTStrCatP(&pszTmp, &cbTmp, "\\\\");
    813                         if (RT_SUCCESS(rc))
    814                             rc = RTStrCatPEx(&pszTmp, &cbTmp, &pszUri[Parsed.offAuthority], Parsed.cchAuthority);
    815                     }
     808                    rc = RTStrCatP(&pszTmp, &cbTmp, "\\\\");
     809                    if (RT_SUCCESS(rc))
     810/** @todo r=bird: YOU MUST DECODE THE STRING!!  */
     811                        rc = RTStrCatPEx(&pszTmp, &cbTmp, &pszUri[Parsed.offAuthority], Parsed.cchAuthority);
    816812                }
    817 
    818                 if (RT_SUCCESS(rc))
    819                     rc = RTStrCatPEx(&pszTmp, &cbTmp, &pszUri[Parsed.offPath], Parsed.cchPath);
    820 
    821                 if (RT_FAILURE(rc))
    822                     RTStrFree(pszResult);
    823813            }
    824             else
    825                 rc = VERR_NO_MEMORY;
    826 
    827         } while (0);
    828 
     814
     815/** @todo r=bird: YOU MUST DECODE THE STRING!!  */
     816            if (RT_SUCCESS(rc))
     817                rc = RTStrCatPEx(&pszTmp, &cbTmp, &pszUri[Parsed.offPath], Parsed.cchPath);
     818
     819            if (RT_FAILURE(rc))
     820                RTStrFree(pszResult);
     821        }
     822        else
     823            rc = VERR_NO_MEMORY;
    829824        if (RT_SUCCESS(rc))
    830825        {
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