VirtualBox

Changeset 86846 in vbox


Ignore:
Timestamp:
Nov 10, 2020 11:13:28 AM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9722: VirtualBox Manager: Extend public key loading validation with file presence check and check whether file size is less than 10KB.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

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

    r86845 r86846  
    10711071    alert(pParent, MessageType_Error,
    10721072          tr("Public key file path is empty."));
     1073}
     1074
     1075void UIMessageCenter::publicKeyFileDoesntExist(const QString &strPath, QWidget *pParent /* = 0 */) const
     1076{
     1077    alert(pParent, MessageType_Error,
     1078          tr("Failed to open the public key file <nobr><b>%1</b></nobr>. File doesn't exist.")
     1079             .arg(strPath));
     1080}
     1081
     1082void UIMessageCenter::publicKeyFileIsOfTooLargeSize(const QString &strPath, QWidget *pParent /* = 0 */) const
     1083{
     1084    alert(pParent, MessageType_Error,
     1085          tr("Failed to open the public key file <nobr><b>%1</b></nobr>. File is too large for the key.")
     1086             .arg(strPath));
    10731087}
    10741088
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r86845 r86846  
    310310    void cannotDeleteConsoleConnection(const CProgress &comProgress, const QString &strMachineName, QWidget *pParent = 0);
    311311    void publicKeyFilePathIsEmpty(QWidget *pParent = 0) const;
     312    void publicKeyFileDoesntExist(const QString &strPath, QWidget *pParent = 0) const;
     313    void publicKeyFileIsOfTooLargeSize(const QString &strPath, QWidget *pParent = 0) const;
    312314    void publicKeyFileIsntReadable(const QString &strPath, QWidget *pParent = 0) const;
    313315
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/UIVirtualBoxManager.cpp

    r86845 r86846  
    246246    }
    247247
     248    /* Make sure file exists and is of suitable size: */
     249    QFileInfo fi(strPath);
     250    if (!fi.exists())
     251    {
     252        if (!fIgnoreErrors)
     253            msgCenter().publicKeyFileDoesntExist(strPath);
     254        return false;
     255    }
     256    if (fi.size() > 10 * _1K)
     257    {
     258        if (!fIgnoreErrors)
     259            msgCenter().publicKeyFileIsOfTooLargeSize(strPath);
     260        return false;
     261    }
     262
    248263    /* Make sure file can be opened: */
    249264    QFile file(strPath);
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