VirtualBox

Ignore:
Timestamp:
Jan 20, 2012 9:13:51 PM (13 years ago)
Author:
vboxsync
Message:

VMMDevReq_ReportGuestInfo2: Validate szName length.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r38663 r39823  
    496496        case VMMDevReq_ReportGuestInfo:
    497497        {
    498             if (pRequestHeader->size != sizeof(VMMDevReportGuestInfo))
    499             {
    500                 AssertMsgFailed(("VMMDev guest information structure has an invalid size!\n"));
    501                 pRequestHeader->rc = VERR_INVALID_PARAMETER;
    502             }
    503             else
    504             {
    505                 VBoxGuestInfo *guestInfo = &((VMMDevReportGuestInfo*)pRequestHeader)->guestInfo;
    506 
    507                 if (memcmp (&pThis->guestInfo, guestInfo, sizeof(*guestInfo)) != 0)
    508                 {
    509                     /* make a copy of supplied information */
    510                     pThis->guestInfo = *guestInfo;
    511 
    512                     /* Check additions version */
    513                     pThis->fu32AdditionsOk = VBOX_GUEST_INTERFACE_VERSION_OK(pThis->guestInfo.interfaceVersion);
    514 
    515                     LogRel(("Guest Additions information report: Interface = 0x%08X osType = 0x%08X\n",
    516                             pThis->guestInfo.interfaceVersion,
    517                             pThis->guestInfo.osType));
    518                     pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
    519                 }
    520 
    521                 if (pThis->fu32AdditionsOk)
    522                 {
    523                     pRequestHeader->rc = VINF_SUCCESS;
    524                 }
    525                 else
    526                 {
    527                     pRequestHeader->rc = VERR_VERSION_MISMATCH;
    528                 }
    529             }
     498            AssertMsgBreakStmt(pRequestHeader->size == sizeof(VMMDevReportGuestInfo), ("%u\n", pRequestHeader->size),
     499                               pRequestHeader->rc = VERR_INVALID_PARAMETER);
     500            VBoxGuestInfo *pGuestInfo = &((VMMDevReportGuestInfo*)pRequestHeader)->guestInfo;
     501
     502            if (memcmp(&pThis->guestInfo, pGuestInfo, sizeof(*pGuestInfo)) != 0)
     503            {
     504                /* make a copy of supplied information */
     505                pThis->guestInfo = *pGuestInfo;
     506
     507                /* Check additions version */
     508                pThis->fu32AdditionsOk = VBOX_GUEST_INTERFACE_VERSION_OK(pThis->guestInfo.interfaceVersion);
     509
     510                LogRel(("Guest Additions information report: Interface = 0x%08X osType = 0x%08X\n",
     511                        pThis->guestInfo.interfaceVersion,
     512                        pThis->guestInfo.osType));
     513                pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
     514            }
     515
     516            if (pThis->fu32AdditionsOk)
     517                pRequestHeader->rc = VINF_SUCCESS;
     518            else
     519                pRequestHeader->rc = VERR_VERSION_MISMATCH;
    530520            break;
    531521        }
     
    533523        case VMMDevReq_ReportGuestInfo2:
    534524        {
    535             if (pRequestHeader->size != sizeof(VMMDevReportGuestInfo2))
    536             {
    537                 AssertMsgFailed(("VMMDev guest information 2 structure has an invalid size!\n"));
    538                 pRequestHeader->rc = VERR_INVALID_PARAMETER;
    539             }
    540             else
    541             {
    542                 VBoxGuestInfo2 *pGuestInfo2 = &((VMMDevReportGuestInfo2*)pRequestHeader)->guestInfo;
    543                 AssertPtr(pGuestInfo2);
    544                 LogRel(("Guest Additions information report: Version %d.%d.%d r%d '%.*s'\n",
    545                         pGuestInfo2->additionsMajor, pGuestInfo2->additionsMinor, pGuestInfo2->additionsBuild,
    546                         pGuestInfo2->additionsRevision, sizeof(pGuestInfo2->szName), pGuestInfo2->szName));
    547                 pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, pGuestInfo2);
    548                 pRequestHeader->rc = VINF_SUCCESS;
    549             }
     525            AssertMsgBreakStmt(pRequestHeader->size == sizeof(VMMDevReportGuestInfo2), ("%u\n", pRequestHeader->size),
     526                               pRequestHeader->rc = VERR_INVALID_PARAMETER);
     527            VBoxGuestInfo2 *pGuestInfo2 = &((VMMDevReportGuestInfo2 *)pRequestHeader)->guestInfo;
     528            LogRel(("Guest Additions information report: Version %d.%d.%d r%d '%.*s'\n",
     529                    pGuestInfo2->additionsMajor, pGuestInfo2->additionsMinor, pGuestInfo2->additionsBuild,
     530                    pGuestInfo2->additionsRevision, sizeof(pGuestInfo2->szName), pGuestInfo2->szName));
     531            AssertBreakStmt(memchr(pGuestInfo2->szName, '\0', sizeof(pGuestInfo2->szName)) != NULL,
     532                            pRequestHeader->rc = VERR_INVALID_PARAMETER);
     533
     534            pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, pGuestInfo2);
     535            pRequestHeader->rc = VINF_SUCCESS;
    550536            break;
    551537        }
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