Changeset 51015 in vbox for trunk/include/VBox
- Timestamp:
- Apr 9, 2014 2:31:21 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 93217
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/shflsvc.h
r51014 r51015 205 205 206 206 /** 207 * Validates a HGCM string outputparameter.207 * Validates a HGCM string parameter. 208 208 * 209 209 * @returns true if valid, false if not. … … 212 212 * @param cbBuf The buffer size from the parameter. 213 213 */ 214 DECLINLINE(bool) ShflStringIsValid Out(PCSHFLSTRING pString, uint32_t cbBuf)214 DECLINLINE(bool) ShflStringIsValid(PCSHFLSTRING pString, uint32_t cbBuf) 215 215 { 216 216 if (RT_UNLIKELY(cbBuf <= RT_UOFFSETOF(SHFLSTRING, String))) … … 220 220 if (RT_UNLIKELY(pString->u16Length >= pString->u16Size)) 221 221 return false; 222 /** @todo r=bird: Check that u16Length is a multiple of two if UTF-16 input? */ 223 /** @todo r=bird: Do we require the string to have a NUL terminator char, if 224 * so check for it!! (Just had a problem with too small (/2) u16Length 225 * and code behaving incorrectly because it worked up to the terminator 226 * instead of the length.) */ 227 /** @todo r=bird: Who checks for valid UTF-8 encoding of strings? */ 222 228 return true; 223 229 } 224 230 225 231 /** 226 * Validates a HGCM string input parameter. 227 * 228 * @returns true if valid, false if not. 229 * 230 * @param pString The string buffer pointer. 231 * @param cbBuf The buffer size from the parameter. 232 * @param fUtf8Not16 Set if UTF-8 encoding, clear if UTF-16 encoding. 233 */ 234 DECLINLINE(bool) ShflStringIsValidIn(PCSHFLSTRING pString, uint32_t cbBuf, bool fUtf8Not16) 235 { 236 int rc; 237 if (RT_UNLIKELY(cbBuf <= RT_UOFFSETOF(SHFLSTRING, String))) 238 return false; 239 if (RT_UNLIKELY((uint32_t)pString->u16Size + RT_UOFFSETOF(SHFLSTRING, String) > cbBuf)) 240 return false; 241 if (fUtf8Not16) 242 { 243 /* UTF-8: */ 244 if (RT_UNLIKELY(pString->u16Length >= pString->u16Size)) 245 return false; 246 rc = RTStrValidateEncodingEx((const char *)&pString->String.utf8[0], pString->u16Length + 1, 247 RTSTR_VALIDATE_ENCODING_EXACT_LENGTH | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED); 248 } 249 else 250 { 251 /* UTF-16: */ 252 if (RT_UNLIKELY(pString->u16Length & 1)) 253 return false; 254 if (RT_UNLIKELY((uint32_t)sizeof(RTUTF16) + pString->u16Length > pString->u16Size)) 255 return false; 256 rc = RTUtf16ValidateEncodingEx(&pString->String.ucs2[0], pString->u16Length / 2 + 1, 257 RTSTR_VALIDATE_ENCODING_EXACT_LENGTH | RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED); 258 } 259 if (RT_FAILURE(rc)) 260 return false; 261 return true; 262 } 263 264 /** 265 * Validates an optional HGCM string input parameter. 232 * Validates an optional HGCM string parameter. 266 233 * 267 234 * @returns true if valid, false if not. … … 269 236 * @param pString The string buffer pointer. Can be NULL. 270 237 * @param cbBuf The buffer size from the parameter. 271 * @param fUtf8Not16 Set if UTF-8 encoding, clear if UTF-16 encoding. 272 */ 273 DECLINLINE(bool) ShflStringIsValidOrNullIn(PCSHFLSTRING pString, uint32_t cbBuf, bool fUtf8Not16) 238 */ 239 DECLINLINE(bool) ShflStringIsValidOrNull(PCSHFLSTRING pString, uint32_t cbBuf) 274 240 { 275 241 if (pString) 276 return ShflStringIsValid In(pString, cbBuf, fUtf8Not16);242 return ShflStringIsValid(pString, cbBuf); 277 243 if (RT_UNLIKELY(cbBuf > 0)) 278 244 return false;
Note:
See TracChangeset
for help on using the changeset viewer.