Changeset 23916 in vbox
- Timestamp:
- Oct 20, 2009 5:14:40 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxGuestLib.h
r23878 r23916 156 156 */ 157 157 DECLVBGL(void) VbglGRFree (VMMDevRequestHeader *pReq); 158 159 /** 160 * Verify the generic request header. 161 * 162 * @param pReq pointer the request header structure. 163 * @param cbReq size of the request memory block. It should be equal to the request size 164 * for fixed size requests. It can be greater than the request size for 165 * variable size requests. 166 * 167 * @return VBox status code. 168 */ 169 DECLVBGL(int) VbglGRVerify (const VMMDevRequestHeader *pReq, size_t cbReq); 158 170 /** @} */ 159 171 -
trunk/src/VBox/Additions/WINNT/VBoxGuest/VBoxGuest.cpp
r21888 r23916 963 963 CHECK_SIZE(vmmdevGetRequestSize(requestHeader->requestType)); 964 964 965 int rc = VbglGRVerify(requestHeader, requestHeader->size); 966 if (RT_FAILURE(rc)) 967 { 968 dprintf(("VBoxGuest::VBoxGuestDeviceControl: VMMREQUEST: invalid header: size %#x, expected >= %#x (hdr); type=%#x; rc %d!!\n", 969 requestHeader->size, vmmdevGetRequestSize(requestHeader->requestType), requestHeader->requestType, rc)); 970 Status = STATUS_INVALID_PARAMETER; 971 break; 972 } 973 965 974 /* just perform the request */ 966 975 VMMDevRequestHeader *req = NULL; 967 976 968 intrc = VbglGRAlloc((VMMDevRequestHeader **)&req, requestHeader->size, requestHeader->requestType);977 rc = VbglGRAlloc((VMMDevRequestHeader **)&req, requestHeader->size, requestHeader->requestType); 969 978 970 979 if (RT_SUCCESS(rc)) -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r23388 r23916 1004 1004 return VERR_INVALID_PARAMETER; 1005 1005 } 1006 int rc = VbglGRVerify(pReqHdr, cbData); 1007 if (RT_FAILURE(rc)) 1008 { 1009 Log(("VBoxGuestCommonIOCtl: VMMREQUEST: invalid header: size %#x, expected >= %#x (hdr); type=%#x; rc %d!!\n", 1010 cbData, cbReq, enmType, rc)); 1011 return rc; 1012 } 1006 1013 1007 1014 /* … … 1013 1020 */ 1014 1021 VMMDevRequestHeader *pReqCopy; 1015 intrc = VbglGRAlloc(&pReqCopy, cbReq, enmType);1022 rc = VbglGRAlloc(&pReqCopy, cbReq, enmType); 1016 1023 if (RT_FAILURE(rc)) 1017 1024 { -
trunk/src/VBox/Additions/common/VBoxGuestLib/GenericRequest.cpp
r21461 r23916 24 24 #include <iprt/assert.h> 25 25 #include <iprt/string.h> 26 27 DECLVBGL(int) VbglGRVerify (const VMMDevRequestHeader *pReq, size_t cbReq) 28 { 29 if (!pReq || cbReq < sizeof (VMMDevRequestHeader)) 30 { 31 dprintf(("VbglGRVerify: Invalid parameter: pReq = %p, cbReq = %d\n", pReq, cbReq)); 32 return VERR_INVALID_PARAMETER; 33 } 34 35 if (pReq->size > cbReq) 36 { 37 dprintf(("VbglGRVerify: request size %d > buffer size %d\n", pReq->size, cbReq)); 38 return VERR_INVALID_PARAMETER; 39 } 40 41 /* The request size must correspond to the request type. */ 42 size_t cbReqExpected = vmmdevGetRequestSize(pReq->requestType); 43 44 if (cbReq < cbReqExpected) 45 { 46 dprintf(("VbglGRVerify: buffer size %d < expected size %d\n", cbReq, cbReqExpected)); 47 return VERR_INVALID_PARAMETER; 48 } 49 50 if (cbReqExpected == cbReq) 51 { 52 /* This is most likely a fixed size request, and in this case the request size 53 * must be also equal to the expected size. 54 */ 55 if (pReq->size != cbReqExpected) 56 { 57 dprintf(("VbglGRVerify: request size %d != expected size %d\n", pReq->size, cbReqExpected)); 58 return VERR_INVALID_PARAMETER; 59 } 60 61 return VINF_SUCCESS; 62 } 63 64 /* This can be a variable size request. Check the request type and limit the size 65 * to VMMDEV_MAX_VMMDEVREQ_SIZE, which is max size supported by the host. 66 */ 67 if ( pReq->requestType == VMMDevReq_LogString 68 || pReq->requestType == VMMDevReq_VideoSetVisibleRegion 69 || pReq->requestType == VMMDevReq_SetPointerShape 70 #ifdef VBOX_WITH_64_BITS_GUESTS 71 || pReq->requestType == VMMDevReq_HGCMCall32 72 || pReq->requestType == VMMDevReq_HGCMCall64 73 #else 74 || pReq->requestType == VMMDevReq_HGCMCall 75 #endif /* VBOX_WITH_64_BITS_GUESTS */ 76 || pReq->requestType == VMMDevReq_ChangeMemBalloon) 77 { 78 if (cbReq > VMMDEV_MAX_VMMDEVREQ_SIZE) 79 { 80 dprintf(("VbglGRVerify: VMMDevReq_LogString: buffer size %d too big\n", cbReq)); 81 return VERR_BUFFER_OVERFLOW; /* @todo is this error code ok? */ 82 } 83 } 84 else 85 { 86 dprintf(("VbglGRVerify: request size %d > buffer size %d\n", pReq->size, cbReq)); 87 return VERR_IO_BAD_LENGTH; /* @todo is this error code ok? */ 88 } 89 90 return VINF_SUCCESS; 91 } 26 92 27 93 DECLVBGL(int) VbglGRAlloc (VMMDevRequestHeader **ppReq, uint32_t cbSize, VMMDevRequestType reqType)
Note:
See TracChangeset
for help on using the changeset viewer.