Changeset 9917 in vbox
- Timestamp:
- Jun 25, 2008 1:57:56 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedInfoServices/service.cpp
r9882 r9917 34 34 * Since the CFGM APIs are single threaded, the creator must also ensure that 35 35 * no-one else accesses the configuration node while the service is running. 36 * 36 * 37 37 * If this service is extended to deal with new requests it would probably be a 38 38 * good idea to split it up into several files. … … 111 111 } 112 112 113 /** 113 /** 114 114 * @copydoc VBOXHGCMSVCHELPERS::pfnConnect 115 115 * Stub implementation of pfnConnect and pfnDisconnect. … … 122 122 } 123 123 124 /** 124 /** 125 125 * @copydoc VBOXHGCMSVCHELPERS::pfnCall 126 126 * Wraps to the call member function … … 139 139 } 140 140 141 /** 142 * @copydoc VBOXHGCMSVCHELPERS::pfnHostCall 141 /** 142 * @copydoc VBOXHGCMSVCHELPERS::pfnHostCall 143 143 * Wraps to the hostCall member function 144 144 */ … … 154 154 private: 155 155 int getKey(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 156 int validateGetKey(const char *p cKey, uint32_t cbKey, char *pcValue, uint32_t cbValue);156 int validateGetKey(const char *pszKey, uint32_t cbKey, char *pszValue, uint32_t cbValue); 157 157 int setKey(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 158 int validateSetKey(const char *p cKey, uint32_t cbKey, char *pcValue, uint32_t cbValue);158 int validateSetKey(const char *pszKey, uint32_t cbKey, char *pszValue, uint32_t cbValue); 159 159 void call (VBOXHGCMCALLHANDLE callHandle, uint32_t u32ClientID, 160 160 void *pvClient, uint32_t eFunction, uint32_t cParms, … … 167 167 * Retrieve a value from the guest registry by key, checking the validity 168 168 * of the arguments passed. 169 * 169 * 170 170 * @returns iprt status value 171 171 * @param cParms the number of HGCM parameters supplied … … 176 176 { 177 177 int rc = VINF_SUCCESS; 178 char *pszKey, *p cValue;178 char *pszKey, *pszValue; 179 179 uint32_t cbKey, cbValue; 180 180 size_t cbValueActual; … … 189 189 rc = VBoxHGCMParmPtrGet(&paParms[0], (void **) &pszKey, &cbKey); 190 190 if (RT_SUCCESS(rc)) 191 rc = VBoxHGCMParmPtrGet(&paParms[1], (void **) &p cValue, &cbValue);192 if (RT_SUCCESS(rc)) 193 rc = validateGetKey(pszKey, cbKey, p cValue, cbValue);191 rc = VBoxHGCMParmPtrGet(&paParms[1], (void **) &pszValue, &cbValue); 192 if (RT_SUCCESS(rc)) 193 rc = validateGetKey(pszKey, cbKey, pszValue, cbValue); 194 194 if (RT_SUCCESS(rc)) 195 195 rc = CFGMR3QuerySize(mpNode, pszKey, &cbValueActual); … … 199 199 rc = VINF_BUFFER_OVERFLOW; 200 200 if (RT_SUCCESS(rc) && (rc != VINF_BUFFER_OVERFLOW)) 201 rc = CFGMR3QueryString(mpNode, pszKey, p cValue, cbValue);201 rc = CFGMR3QueryString(mpNode, pszKey, pszValue, cbValue); 202 202 if (RT_SUCCESS(rc) && (rc != VINF_BUFFER_OVERFLOW)) 203 Log2(("Queried string %s, rc=%Rrc, value=%.*s\n", pszKey, rc, cbValue, p cValue));203 Log2(("Queried string %s, rc=%Rrc, value=%.*s\n", pszKey, rc, cbValue, pszValue)); 204 204 else if (VERR_CFGM_VALUE_NOT_FOUND == rc) 205 205 { … … 218 218 * 219 219 * @returns IPRT status code 220 * @param p cKeythe key passed by the guest221 * @param cbKey the number of bytes in the array cbKey222 * @param p cValue the array to store the keyinto220 * @param pszKey the key passed by the guest 221 * @param cbKey the number of bytes pszKey points to, including the terminating '\0' 222 * @param pszValue the buffer to store the key name into 223 223 * @param cbValue the size of the array for storing the key value 224 224 * @thread HGCM 225 225 */ 226 int Service::validateGetKey(const char *p cKey, uint32_t cbKey, char *pcValue, uint32_t cbValue)226 int Service::validateGetKey(const char *pszKey, uint32_t cbKey, char *pszValue, uint32_t cbValue) 227 227 { 228 228 LogFlowFunc(("cbKey=%d, cbValue=%d\n", cbKey, cbValue)); … … 235 235 rc = VERR_INVALID_PARAMETER; 236 236 /* Only accept names in printable ASCII without spaces */ 237 for (count = 0; (count < cbKey) && (p cKey[count] != '\0'); ++count)238 if ((p cKey[count] < 33) || (pcKey[count] > 126))237 for (count = 0; (count < cbKey) && (pszKey[count] != '\0'); ++count) 238 if ((pszKey[count] < 33) || (pszKey[count] > 126)) 239 239 rc = VERR_INVALID_PARAMETER; 240 240 if (RT_SUCCESS(rc) && (count == cbKey)) … … 245 245 246 246 if (RT_SUCCESS(rc)) 247 LogFlow((" p cKey=%s\n", pcKey));247 LogFlow((" pszKey=%s\n", pszKey)); 248 248 LogFlowFunc(("returning %Rrc\n", rc)); 249 249 return rc; … … 254 254 * Set a value in the guest registry by key, checking the validity 255 255 * of the arguments passed. 256 * 256 * 257 257 * @returns iprt status value 258 258 * @param cParms the number of HGCM parameters supplied … … 306 306 * 307 307 * @returns IPRT status code 308 * @param p cKeythe key passed by the guest309 * @param cbKey the number of bytes in the array cbKey310 * @param p cValuethe value to store in the key311 * @param cbValue the number of bytes in the array pcValue308 * @param pszKey the key passed by the guest 309 * @param cbKey the number of bytes in the buffer pszKey points to 310 * @param pszValue the value to store in the key 311 * @param cbValue the number of bytes in the buffer pszValue points to 312 312 * @thread HGCM 313 313 */ 314 int Service::validateSetKey(const char *p cKey, uint32_t cbKey, char *pcValue,314 int Service::validateSetKey(const char *pszKey, uint32_t cbKey, char *pszValue, 315 315 uint32_t cbValue) 316 316 { … … 323 323 if (cbKey < sizeof(VBOX_SHARED_INFO_KEY_PREFIX)) 324 324 rc = VERR_INVALID_PARAMETER; 325 /** @todo duplicate check in validateGetKey, use separate method. mixing unsigned and uint32_t. */ 325 326 /* Only accept names in printable ASCII without spaces */ 326 for (count = 0; (count < cbKey) && (p cKey[count] != '\0'); ++count)327 if ((p cKey[count] < 33) || (pcKey[count] > 126))327 for (count = 0; (count < cbKey) && (pszKey[count] != '\0'); ++count) 328 if ((pszKey[count] < 33) || (pszKey[count] > 126)) 328 329 rc = VERR_INVALID_PARAMETER; 329 330 if (RT_SUCCESS(rc) && (count == cbKey)) … … 337 338 /* Validate the format of the value. */ 338 339 /* Only accept values in printable ASCII without spaces */ 339 for (count = 0; (count < cbValue) && (p cValue[count] != '\0'); ++count)340 if ((p cValue[count] < 33) || (pcValue[count] > 126))340 for (count = 0; (count < cbValue) && (pszValue[count] != '\0'); ++count) 341 if ((pszValue[count] < 33) || (pszValue[count] > 126)) 341 342 rc = VERR_INVALID_PARAMETER; 342 343 if (RT_SUCCESS(rc) && (count == cbValue)) … … 348 349 349 350 if (RT_SUCCESS(rc)) 350 LogFlow((" p cKey=%s, pcValue=%s\n", pcKey, cbValue > 0 ? pcValue : NULL));351 LogFlow((" pszKey=%s, pszValue=%s\n", pszKey, cbValue > 0 ? pszValue : NULL)); 351 352 LogFlowFunc(("returning %Rrc\n", rc)); 352 353 return rc; … … 360 361 * handled synchronously. If needed, we will add a request handler 361 362 * thread in future for those which do. 362 * 363 * 363 364 * @thread HGCM 364 365 */
Note:
See TracChangeset
for help on using the changeset viewer.