- Timestamp:
- Mar 28, 2009 4:04:18 AM (16 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuestLib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/VBGLR3Internal.h
r10797 r18451 81 81 } 82 82 83 84 #ifdef ___iprt_string_h 85 86 DECLINLINE(void) VbglHGCMParmPtrSetString(HGCMFunctionParameter *pParm, const char *psz) 87 { 88 pParm->type = VMMDevHGCMParmType_LinAddr; 89 pParm->u.Pointer.size = (uint32_t)strlen(psz) + 1; 90 pParm->u.Pointer.u.linearAddr = (uintptr_t)psz; 91 } 92 93 #endif /* ___iprt_string_h */ 94 83 95 __END_DECLS 84 96 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp
r14359 r18451 124 124 Msg.hdr.u32Function = SET_PROP_VALUE; 125 125 Msg.hdr.cParms = 3; 126 VbglHGCMParmPtrSet (&Msg.name, const_cast<char *>(pszName), strlen(pszName) + 1);127 VbglHGCMParmPtrSet (&Msg.value, const_cast<char *>(pszValue), strlen(pszValue) + 1);128 VbglHGCMParmPtrSet (&Msg.flags, const_cast<char *>(pszFlags), strlen(pszFlags) + 1);126 VbglHGCMParmPtrSetString(&Msg.name, pszName); 127 VbglHGCMParmPtrSetString(&Msg.value, pszValue); 128 VbglHGCMParmPtrSetString(&Msg.flags, pszFlags); 129 129 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 130 130 if (RT_SUCCESS(rc)) … … 139 139 Msg.hdr.u32Function = DEL_PROP; 140 140 Msg.hdr.cParms = 1; 141 VbglHGCMParmPtrSet (&Msg.name, const_cast<char *>(pszName), strlen(pszName) + 1);141 VbglHGCMParmPtrSetString(&Msg.name, pszName); 142 142 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 143 143 if (RT_SUCCESS(rc)) … … 173 173 Msg.hdr.u32Function = SET_PROP_VALUE; 174 174 Msg.hdr.cParms = 2; 175 VbglHGCMParmPtrSet (&Msg.name, const_cast<char *>(pszName), strlen(pszName) + 1);176 VbglHGCMParmPtrSet (&Msg.value, const_cast<char *>(pszValue), strlen(pszValue) + 1);175 VbglHGCMParmPtrSetString(&Msg.name, pszName); 176 VbglHGCMParmPtrSetString(&Msg.value, pszValue); 177 177 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 178 178 if (RT_SUCCESS(rc)) … … 187 187 Msg.hdr.u32Function = DEL_PROP; 188 188 Msg.hdr.cParms = 1; 189 VbglHGCMParmPtrSet (&Msg.name, const_cast<char *>(pszName), strlen(pszName) + 1);189 VbglHGCMParmPtrSetString(&Msg.name, pszName); 190 190 rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg)); 191 191 if (RT_SUCCESS(rc)) … … 281 281 Msg.hdr.u32Function = GET_PROP; 282 282 Msg.hdr.cParms = 4; 283 VbglHGCMParmPtrSet (&Msg.name, const_cast<char *>(pszName), strlen(pszName) + 1);283 VbglHGCMParmPtrSetString(&Msg.name, pszName); 284 284 VbglHGCMParmPtrSet(&Msg.buffer, pvBuf, cbBuf); 285 285 VbglHGCMParmUInt64Set(&Msg.timestamp, 0); … … 442 442 uint32_t *pcchValueActual) 443 443 { 444 char *p cBuf = NULL;445 int rc = VbglR3GuestPropReadValueAlloc(u32ClientId, pszName, &p cBuf);444 char *pszBuf = NULL; 445 int rc = VbglR3GuestPropReadValueAlloc(u32ClientId, pszName, &pszBuf); 446 446 if (RT_SUCCESS(rc)) 447 447 { 448 uint32_t cchValueActual = strlen(pcBuf) + 1; 449 if (cchValueActual > cchValue) 448 size_t cchValueActual = strlen(pszBuf) + 1; 449 if (cchValueActual <= cchValue) 450 memcpy(pszValue, pszBuf, cchValueActual); 451 else 450 452 { 451 453 if (pcchValueActual != NULL) 452 *pcchValueActual = cchValueActual;454 *pcchValueActual = (uint32_t)cchValueActual; 453 455 rc = VERR_BUFFER_OVERFLOW; 454 456 } 455 if (RT_SUCCESS(rc)) 456 strcpy(pszValue, pcBuf); 457 } 458 VbglR3GuestPropReadValueFree(pcBuf); 457 } 458 VbglR3GuestPropReadValueFree(pszBuf); 459 459 return rc; 460 460 } … … 495 495 Msg.hdr.cParms = 3; 496 496 /* Get the length of the patterns array... */ 497 uint32_t cchPatterns = 0;498 for ( uint32_t cchCurrent = strlen(pszzPatterns); cchCurrent != 0;497 size_t cchPatterns = 0; 498 for (size_t cchCurrent = strlen(pszzPatterns); cchCurrent != 0; 499 499 cchCurrent = strlen(pszzPatterns + cchPatterns)) 500 500 cchPatterns += cchCurrent + 1; 501 501 /* ...including the terminator. */ 502 502 ++cchPatterns; 503 VbglHGCMParmPtrSet(&Msg.patterns, const_cast<char *>(pszzPatterns), 504 cchPatterns); 503 VbglHGCMParmPtrSet(&Msg.patterns, (char *)pszzPatterns, (uint32_t)cchPatterns); 505 504 VbglHGCMParmPtrSet(&Msg.strings, pcBuf, cbBuf); 506 505 VbglHGCMParmUInt32Set(&Msg.size, 0); … … 570 569 571 570 /* Get the length of the pattern string, including the final terminator. */ 572 uint32_t cchPatterns = 1;573 for (u nsignedi = 0; i < cPatterns; ++i)571 size_t cchPatterns = 1; 572 for (uint32_t i = 0; i < cPatterns; ++i) 574 573 cchPatterns += strlen(papszPatterns[i]) + 1; 575 574 … … 577 576 RTMemAutoPtr<char> Patterns; 578 577 Patterns = (char *)RTMemAlloc(cchPatterns); 579 uint32_t iOffs= 0;578 size_t off = 0; 580 579 for (uint32_t i = 0; i < cPatterns; ++i) 581 580 { 582 uint32_t cb = strlen(papszPatterns[i]) + 1;583 memcpy(&Patterns[ iOffs], papszPatterns[i], cb);584 iOffs+= cb;585 } 586 Patterns[ iOffs] = '\0';581 size_t cb = strlen(papszPatterns[i]) + 1; 582 memcpy(&Patterns[off], papszPatterns[i], cb); 583 off += cb; 584 } 585 Patterns[off] = '\0'; 587 586 588 587 /* Randomly chosen initial size for the buffer to hold the enumeration … … 841 840 Msg.hdr.info.u32Function = GET_NOTIFICATION; 842 841 Msg.hdr.info.cParms = 4; 843 Msg.patterns.SetPtr(const_cast<char *>(pszPatterns), 844 strlen(pszPatterns) + 1); 842 VbglHGCMParmPtrSetString(&Msg.patterns, pszPatterns); 845 843 Msg.buffer.SetPtr(pvBuf, cbBuf); 846 844 Msg.timestamp.SetUInt64(u64Timestamp);
Note:
See TracChangeset
for help on using the changeset viewer.