VirtualBox

Ignore:
Timestamp:
Feb 6, 2019 8:03:07 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128677
Message:

FE/Qt: Correctly escape VISO volume labels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r77186 r77188  
    26342634}
    26352635
     2636
     2637/**
     2638 * Helper for createVisoMediumWithVisoCreator.
     2639 * @returns IPRT status code.
     2640 * @param   pStrmDst            Where to write the quoted string.
     2641 * @param   pszPrefix           Stuff to put in front of it.
     2642 * @param   rStr                The string to quote and write out.
     2643 * @param   pszPrefix           Stuff to put after it.
     2644 */
     2645DECLINLINE(int) visoWriteQuotedString(PRTSTREAM pStrmDst, const char *pszPrefix, QString const &rStr, const char *pszPostFix)
     2646{
     2647    QByteArray const utf8Array   = rStr.toUtf8();
     2648    const char      *apszArgv[2] = { utf8Array.constData(), NULL };
     2649    char            *pszQuoted;
     2650    int vrc = RTGetOptArgvToString(&pszQuoted, apszArgv, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH);
     2651    if (RT_SUCCESS(vrc))
     2652    {
     2653        if (pszPrefix)
     2654            vrc = RTStrmPutStr(pStrmDst, pszPrefix);
     2655        if (RT_SUCCESS(vrc))
     2656        {
     2657            vrc = RTStrmPutStr(pStrmDst, pszQuoted);
     2658            if (pszPostFix && RT_SUCCESS(vrc))
     2659                vrc = RTStrmPutStr(pStrmDst, pszPostFix);
     2660        }
     2661        RTStrFree(pszQuoted);
     2662    }
     2663
     2664    return vrc;
     2665}
     2666
     2667
    26362668QUuid VBoxGlobal::createVisoMediumWithVisoCreator(QWidget *pParent, const QString &strMachineName, const QString &strFolder)
    26372669{
     
    26712703                {
    26722704                    RTStrmPrintf(pStrmViso, "--iprt-iso-maker-file-marker-bourne-sh %RTuuid\n", &Uuid);
    2673                     RTStrmPrintf(pStrmViso, "--volume-id=%s\n", strVisoName.toUtf8().constData());
    2674 
    2675                     for (int iFile = 0; iFile < files.size(); iFile++)
    2676                     {
    2677                         QByteArray const utf8Name = files[iFile].toUtf8();
    2678                         const char *apszArgv[2] = { utf8Name.constData(), NULL };
    2679                         char *pszQuoted;
    2680                         vrc = RTGetOptArgvToString(&pszQuoted, apszArgv, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH);
    2681                         if (RT_SUCCESS(vrc))
    2682                         {
    2683                             RTStrmPrintf(pStrmViso, "%s\n", pszQuoted);
    2684                             RTStrFree(pszQuoted);
    2685                         }
    2686                         else
    2687                             break;
    2688                     }
     2705                    vrc = visoWriteQuotedString(pStrmViso, "--volume-id=", strVisoName, "\n");
     2706
     2707                    for (int iFile = 0; iFile < files.size() && RT_SUCCESS(vrc); iFile++)
     2708                        vrc = visoWriteQuotedString(pStrmViso, NULL, files[iFile], "\n");
     2709
    26892710                    /* Append custom options if any to the file: */
    26902711                    const QStringList &customOptions = pVisoCreator->customOptions();
Note: See TracChangeset for help on using the changeset viewer.

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