VirtualBox

Ignore:
Timestamp:
Mar 28, 2017 11:51:16 AM (8 years ago)
Author:
vboxsync
Message:

VBoxManage extpack install: Lower case the digest; use stack buffer for digest too; don't convert the license to UTF-8 twice.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r66204 r66295  
    11441144                case 'a':
    11451145                    lstLicenseHashes.append(ValueUnion.psz);
     1146                    lstLicenseHashes[lstLicenseHashes.size() - 1].toLower();
    11461147                    break;
    11471148
     
    11811182            Utf8Str strLicense(bstrLicense);
    11821183            uint8_t abHash[RTSHA256_HASH_SIZE];
     1184            char    szDigest[RTSHA256_DIGEST_LEN + 1];
    11831185            RTSha256(strLicense.c_str(), strLicense.length(), abHash);
    1184             char *pszDigest = NULL;
    1185             vrc = RTStrAllocEx(&pszDigest, RTSHA256_DIGEST_LEN + 1);
    1186             if (RT_SUCCESS(vrc))
    1187                 RTSha256ToString(abHash, pszDigest, RTSHA256_DIGEST_LEN + 1);
    1188             if (   pszDigest
    1189                 && lstLicenseHashes.contains(pszDigest))
     1186            vrc = RTSha256ToString(abHash, szDigest, sizeof(szDigest));
     1187            AssertRCStmt(vrc, szDigest[0] = '\0');
     1188            if (lstLicenseHashes.contains(szDigest))
    11901189                RTPrintf("License accepted.\n");
    11911190            else
    11921191            {
    1193                 RTPrintf("%ls\n", bstrLicense.raw());
     1192                RTPrintf("%s\n", srcLicense.c_str());
    11941193                RTPrintf("Do you agree to these license terms and conditions (y/n)? " );
    11951194                ch = RTStrmGetCh(g_pStdIn);
     
    11981197                {
    11991198                    RTPrintf("Installation of \"%ls\" aborted.\n", bstrName.raw());
    1200                     if (pszDigest)
    1201                         RTStrFree(pszDigest);
    12021199                    return RTEXITCODE_SUCCESS;
    12031200                }
    1204                 if (pszDigest)
    1205                 {
     1201                if (szDigest[0])
    12061202                    RTPrintf("License accepted. For batch installaltion add\n"
    12071203                             "--accept-license=%s\n"
    1208                              "to the VBoxManage command line.\n\n", pszDigest);
    1209                 }
    1210             }
    1211             if (pszDigest)
    1212                 RTStrFree(pszDigest);
     1204                             "to the VBoxManage command line.\n\n", szDigest);
     1205            }
    12131206        }
    12141207        ComPtr<IProgress> ptrProgress;
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