Changeset 58156 in vbox
- Timestamp:
- Oct 9, 2015 3:12:28 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/VMMDev/VMMDev.cpp
r58132 r58156 840 840 * Validate input. 841 841 */ 842 AssertMsgReturn(pReqHdr->size >= sizeof(VMMDevReportGuestUserState), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);843 VBoxGuestUserStatus *pStatus = &((VMMDevReportGuestUserState *)pReqHdr)->status;842 VMMDevReportGuestUserState *pReq = (VMMDevReportGuestUserState *)pReqHdr; 843 AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER); 844 844 845 845 if ( pThis->pDrv 846 846 && pThis->pDrv->pfnUpdateGuestUserState) 847 847 { 848 AssertPtr(pStatus); 849 850 if ( pReqHdr->size > _2K 851 || pStatus->cbUser > 256 852 || pStatus->cbDomain > 256 853 || pStatus->cbDetails > _1K) /* Play safe. */ 854 { 855 return VERR_INVALID_PARAMETER; 856 } 857 858 /* pyDynamic marks the beginning of the struct's dynamically 848 /* Play safe. */ 849 AssertReturn(pReq->header.size <= _2K, VERR_TOO_MUCH_DATA); 850 AssertReturn(pReq->status.cbUser <= 256, VERR_TOO_MUCH_DATA); 851 AssertReturn(pReq->status.cbDomain <= 256, VERR_TOO_MUCH_DATA); 852 AssertReturn(pReq->status.cbDetails <= _1K, VERR_TOO_MUCH_DATA); 853 854 /* pbDynamic marks the beginning of the struct's dynamically 859 855 * allocated data area. */ 860 uint8_t *pvDynamic = (uint8_t *)pStatus + RT_OFFSETOF(VBoxGuestUserStatus, szUser); 861 AssertPtr(pvDynamic); 862 863 if (!pStatus->cbUser) /* User name is required. */ 864 return VERR_INVALID_PARAMETER; 865 const char *pszUser = (const char *)pvDynamic; 866 AssertPtrReturn(pszUser, VERR_INVALID_POINTER); 867 868 pvDynamic += pStatus->cbUser; /* Advance to next field. */ 869 const char *pszDomain = pStatus->cbDomain 870 ? (const char *)pvDynamic : NULL; 871 /* Note: pszDomain can be NULL. */ 872 873 pvDynamic += pStatus->cbDomain; /* Advance to next field. */ 874 const uint8_t *puDetails = pStatus->cbDetails 875 ? pvDynamic : NULL; 876 /* Note: puDetails can be NULL. */ 877 878 pThis->pDrv->pfnUpdateGuestUserState(pThis->pDrv, pszUser, pszDomain, 879 /* State */ 880 (uint32_t)pStatus->state, 881 /* State details */ 882 puDetails, 883 pStatus->cbDetails); 856 uint8_t *pbDynamic = (uint8_t *)&pReq->status.szUser; 857 uint32_t cbLeft = pReqHdr->size - RT_OFFSETOF(VMMDevReportGuestUserState, status.szUser); 858 859 /* The user. */ 860 AssertReturn(pReq->status.cbUser > 0, VERR_INVALID_PARAMETER); /* User name is required. */ 861 AssertReturn(pReq->status.cbUser <= cbLeft, VERR_INVALID_PARAMETER); 862 const char *pszUser = (const char *)pbDynamic; 863 AssertReturn(RTStrEnd(pszUser, pReq->status.cbUser), VERR_INVALID_PARAMETER); 864 int rc = RTStrValidateEncoding(pszUser); 865 AssertRCReturn(rc, rc); 866 867 /* Advance to the next field. */ 868 pbDynamic += pReq->status.cbUser; 869 cbLeft -= pReq->status.cbUser; 870 871 /* pszDomain can be NULL. */ 872 AssertReturn(pReq->status.cbDomain <= cbLeft, VERR_INVALID_PARAMETER); 873 const char *pszDomain = NULL; 874 if (pReq->status.cbDomain) 875 { 876 pszDomain = (const char *)pbDynamic; 877 AssertReturn(RTStrEnd(pszDomain, pReq->status.cbDomain), VERR_INVALID_PARAMETER); 878 rc = RTStrValidateEncoding(pszDomain); 879 AssertRCReturn(rc, rc); 880 881 /* Advance to the next field. */ 882 pbDynamic += pReq->status.cbDomain; 883 cbLeft -= pReq->status.cbDomain; 884 } 885 886 /* pbDetails can be NULL. */ 887 const uint8_t *pbDetails = NULL; 888 AssertReturn(pReq->status.cbDetails <= cbLeft, VERR_INVALID_PARAMETER); 889 if (pReq->status.cbDetails > 0) 890 pbDetails = pbDynamic; 891 892 pThis->pDrv->pfnUpdateGuestUserState(pThis->pDrv, pszUser, pszDomain, (uint32_t)pReq->status.state, 893 pbDetails, pReq->status.cbDetails); 884 894 } 885 895
Note:
See TracChangeset
for help on using the changeset viewer.