Changeset 23916 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Oct 20, 2009 5:14:40 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.