Changeset 102667 in vbox for trunk/src/VBox/Main/include
- Timestamp:
- Dec 21, 2023 9:20:02 AM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r102654 r102667 1214 1214 * Returns the payload as a vector of strings, validated. 1215 1215 * 1216 * The payload data must contain the strings separated by a string zero terminator each, 1217 * ending with a separate zero terminator. Incomplete data will considered as invalid data. 1218 * 1219 * Example: 'foo\0bar\0baz\0\0'. 1220 * 1216 1221 * @returns VBox status code. 1217 1222 * @param vecStrings Where to return the vector of strings on success. … … 1224 1229 1225 1230 const char *psz = (const char *)pvData; 1226 AssertPtrReturn(psz, vrc = VERR_INVALID_PARAMETER); 1227 size_t cb = cbData; 1228 while (cb) 1229 { 1230 size_t const cch = strlen(psz); 1231 if (!cch) 1232 break; 1233 size_t const cbStr = cch + 1 /* String terminator */; 1234 vrc = RTStrValidateEncodingEx(psz, cbStr, 1235 RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED | RTSTR_VALIDATE_ENCODING_EXACT_LENGTH); 1236 if (RT_FAILURE(vrc)) 1237 break; 1238 AssertBreakStmt(cb >= cbStr, vrc = VERR_INVALID_PARAMETER); 1239 cb -= cbStr; 1240 psz += cbStr; 1231 if (psz) 1232 { 1233 size_t cb = cbData; 1234 while (cb) 1235 { 1236 size_t const cch = strnlen(psz, cb); 1237 if (!cch) 1238 break; 1239 size_t const cbStr = RT_MIN(cb, cch + 1 /* String terminator */); 1240 vrc = RTStrValidateEncodingEx(psz, cbStr, 1241 RTSTR_VALIDATE_ENCODING_ZERO_TERMINATED | RTSTR_VALIDATE_ENCODING_EXACT_LENGTH); 1242 if (RT_FAILURE(vrc)) 1243 break; 1244 try 1245 { 1246 vecStrings.push_back(Utf8Str(psz, cch)); 1247 } 1248 catch (std::bad_alloc &) 1249 { 1250 AssertFailedBreakStmt(vrc = VERR_NO_MEMORY); 1251 } 1252 AssertBreakStmt(cb >= cbStr, vrc = VERR_INVALID_PARAMETER); 1253 cb -= cbStr; 1254 psz += cbStr; 1255 } 1256 1257 if (RT_SUCCESS(vrc)) 1258 AssertStmt(cb <= 1 /* Ending terminator */, vrc = VERR_INVALID_PARAMETER); 1241 1259 } 1242 1243 if (RT_SUCCESS(vrc))1244 AssertStmt(cb <= 1 /* Ending terminator */, vrc = VERR_INVALID_PARAMETER);1245 1260 return vrc; 1246 1261 }
Note:
See TracChangeset
for help on using the changeset viewer.