- Timestamp:
- Dec 5, 2018 5:29:39 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/service.cpp
r75981 r75984 48 48 #include <iprt/cpp/autores.h> 49 49 #include <iprt/cpp/utils.h> 50 #include <iprt/cpp/ministring.h> 50 51 #include <iprt/err.h> 51 52 #include <iprt/mem.h> … … 57 58 #include <VBox/version.h> 58 59 59 #include <string>60 60 #include <list> 61 61 … … 73 73 RTSTRSPACECORE mStrCore; 74 74 /** The name of the property */ 75 std::string mName;75 RTCString mName; 76 76 /** The property value */ 77 std::string mValue;77 RTCString mValue; 78 78 /** The timestamp of the property */ 79 79 uint64_t mTimestamp; … … 87 87 } 88 88 /** Constructor with const char * */ 89 Property(const char *pcszName, const char *pcszValue, 90 uint64_t u64Timestamp, uint32_t u32Flags) 91 : mName(pcszName), mValue(pcszValue), mTimestamp(u64Timestamp), 92 mFlags(u32Flags) 89 Property(const char *pcszName, const char *pcszValue, uint64_t nsTimestamp, uint32_t u32Flags) 90 : mName(pcszName) 91 , mValue(pcszValue) 92 , mTimestamp(nsTimestamp) 93 , mFlags(u32Flags) 93 94 { 94 95 RT_ZERO(mStrCore); … … 96 97 } 97 98 /** Constructor with std::string */ 98 Property(std::string name, std::string value, uint64_t u64Timestamp, 99 uint32_t u32Flags) 100 : mName(name), mValue(value), mTimestamp(u64Timestamp), 101 mFlags(u32Flags) 99 Property(RTCString const &rName, RTCString const &rValue, uint64_t nsTimestamp, uint32_t fFlags) 100 : mName(rName) 101 , mValue(rValue) 102 , mTimestamp(nsTimestamp) 103 , mFlags(fFlags) 102 104 {} 103 105 … … 129 131 bool isNull() 130 132 { 131 return mName. empty();133 return mName.isEmpty(); 132 134 } 133 135 }; … … 234 236 for (; it != mGuestNotifications.end() 235 237 && it->mTimestamp != u64Timestamp; ++it) 236 {}238 { /*nothing*/ } 237 239 if (it == mGuestNotifications.end()) /* Not found */ 238 240 it = mGuestNotifications.begin(); … … 668 670 /* Check that the buffer is big enough */ 669 671 size_t const cbFlags = strlen(szFlags) + 1; 670 size_t const cbValue = pProp->mValue. size() + 1;672 size_t const cbValue = pProp->mValue.length() + 1; 671 673 size_t const cbNeeded = cbValue + cbFlags; 672 674 HGCMSvcSetU32(&paParms[3], (uint32_t)cbNeeded); … … 1085 1087 1086 1088 /* Format the data to write to the buffer. */ 1087 std::string buffer; 1088 uint64_t u64Timestamp; 1089 char *pchBuf; 1089 char *pchBuf; 1090 1090 uint32_t cbBuf; 1091 1092 1091 int rc = HGCMSvcGetBuf(&paParms[2], (void **)&pchBuf, &cbBuf); 1093 1092 if (RT_SUCCESS(rc)) … … 1097 1096 if (RT_SUCCESS(rc)) 1098 1097 { 1099 buffer += prop.mName; 1100 buffer += '\0'; 1101 buffer += prop.mValue; 1102 buffer += '\0'; 1103 buffer += szFlags; 1104 buffer += '\0'; 1105 u64Timestamp = prop.mTimestamp; 1106 1107 /* Write out the data. */ 1108 if (RT_SUCCESS(rc)) 1098 HGCMSvcSetU64(&paParms[1], prop.mTimestamp); 1099 1100 size_t const cbFlags = strlen(szFlags) + 1; 1101 size_t const cbName = prop.mName.length() + 1; 1102 size_t const cbValue = prop.mValue.length() + 1; 1103 size_t const cbNeeded = cbName + cbValue + cbFlags; 1104 HGCMSvcSetU32(&paParms[3], (uint32_t)cbNeeded); 1105 if (cbNeeded <= cbBuf) 1109 1106 { 1110 HGCMSvcSetU64(&paParms[1], u64Timestamp); 1111 HGCMSvcSetU32(&paParms[3], (uint32_t)buffer.size()); 1112 if (buffer.size() <= cbBuf) 1113 buffer.copy(pchBuf, cbBuf); 1114 else 1115 rc = VERR_BUFFER_OVERFLOW; 1107 memcpy(pchBuf, prop.mName.c_str(), cbName); 1108 pchBuf += cbName; 1109 memcpy(pchBuf, prop.mValue.c_str(), cbValue); 1110 pchBuf += cbValue; 1111 memcpy(pchBuf, szFlags, cbFlags); 1116 1112 } 1113 else 1114 rc = VERR_BUFFER_OVERFLOW; 1117 1115 } 1118 1116 }
Note:
See TracChangeset
for help on using the changeset viewer.