Changeset 79777 in vbox for trunk/src/VBox/NetworkServices/Dhcpd
- Timestamp:
- Jul 15, 2019 12:28:50 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/NetworkServices/Dhcpd/DhcpOptions.cpp
r79763 r79777 241 241 /*static*/ int DhcpOption::parseList(std::vector<uint8_t> &aList, const char *pcszValue) 242 242 { 243 uint8_t abBuf[256]; 244 const char *pszNext = NULL; 245 size_t cbReturned = 0; 243 uint8_t abBuf[255]; 244 size_t cbReturned = 0; 246 245 int rc = RTStrConvertHexBytesEx(RTStrStripL(pcszValue), abBuf, sizeof(abBuf), RTSTRCONVERTHEXBYTES_F_SEP_COLON, 247 &pszNext, &cbReturned);246 NULL, &cbReturned); 248 247 if (RT_SUCCESS(rc)) 249 248 { 250 if (pszNext) 251 pszNext = RTStrStripL(pszNext); 252 if (*pszNext) 249 if (rc != VWRN_TRAILING_CHARS) 253 250 { 254 251 for (size_t i = 0; i < cbReturned; i++) 255 252 aList.push_back(abBuf[i]); 256 r eturnVINF_SUCCESS;253 rc = VINF_SUCCESS; 257 254 } 258 rc = VERR_TRAILING_CHARS; 255 else 256 rc = VERR_TRAILING_CHARS; 259 257 } 260 258 return rc; … … 268 266 int DhcpOption::parseHex(octets_t &aRawValue, const char *pcszValue) 269 267 { 270 octets_t data; 271 char *pszNext; 272 int rc; 273 274 if (pcszValue == NULL || *pcszValue == '\0') 275 return VERR_INVALID_PARAMETER; 276 277 while (*pcszValue != '\0') 278 { 279 if (data.size() > UINT8_MAX) 280 return VERR_INVALID_PARAMETER; 281 282 uint8_t u8Byte; 283 rc = RTStrToUInt8Ex(pcszValue, &pszNext, 16, &u8Byte); 284 if (!RT_SUCCESS(rc)) 285 return rc; 286 287 if (*pszNext == ':') 288 ++pszNext; 289 else if (*pszNext != '\0') 290 return VERR_PARSE_ERROR; 291 292 data.push_back(u8Byte); 293 pcszValue = pszNext; 294 } 295 296 aRawValue.swap(data); 297 return VINF_SUCCESS; 268 uint8_t abBuf[255]; 269 size_t cbReturned = 0; 270 int rc = RTStrConvertHexBytesEx(RTStrStripL(pcszValue), abBuf, sizeof(abBuf), RTSTRCONVERTHEXBYTES_F_SEP_COLON, 271 NULL, &cbReturned); 272 if (RT_SUCCESS(rc)) 273 { 274 if (rc != VWRN_TRAILING_CHARS) 275 { 276 for (size_t i = 0; i < cbReturned; i++) 277 aRawValue.push_back(abBuf[i]); 278 rc = VINF_SUCCESS; 279 } 280 else 281 rc = VERR_TRAILING_CHARS; 282 } 283 return rc; 298 284 } 299 285
Note:
See TracChangeset
for help on using the changeset viewer.