Changeset 45227 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Mar 28, 2013 12:22:11 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/checksum/manifest.cpp
r44529 r45227 268 268 } 269 269 270 271 RTR3DECL(int) RTManifestVerifyDigestType(void *pvBuf, size_t cbSize, RTDIGESTTYPE &digestType) 272 { 273 /* Validate input */ 274 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 275 AssertReturn(cbSize > 0, VERR_INVALID_PARAMETER); 276 277 int rc = VINF_SUCCESS; 278 279 char *pcBuf = (char*)pvBuf; 280 size_t cbRead = 0; 281 /* Parse the manifest file line by line */ 282 for (;;) 283 { 284 if (cbRead >= cbSize) 285 { 286 digestType = RTDIGESTTYPE_UNKNOWN; 287 rc = VERR_MANIFEST_UNSUPPORTED_DIGEST_TYPE; 288 break; 289 } 290 291 size_t cch = rtManifestIndexOfCharInBuf(pcBuf, cbSize - cbRead, '\n') + 1; 292 293 /* Skip empty lines (UNIX/DOS format) */ 294 if ( ( cch == 1 295 && pcBuf[0] == '\n') 296 || ( cch == 2 297 && pcBuf[0] == '\r' 298 && pcBuf[1] == '\n')) 299 { 300 pcBuf += cch; 301 cbRead += cch; 302 continue; 303 } 304 305 /* Check for the digest algorithm */ 306 if (pcBuf[0] == 'S' 307 && pcBuf[1] == 'H' 308 && pcBuf[2] == 'A' 309 && pcBuf[3] == '1') 310 { 311 digestType = RTDIGESTTYPE_SHA1; 312 break; 313 } 314 else if (pcBuf[0] == 'S' 315 && pcBuf[1] == 'H' 316 && pcBuf[2] == 'A' 317 && pcBuf[3] == '2' 318 && pcBuf[4] == '5' 319 && pcBuf[5] == '6') 320 { 321 digestType = RTDIGESTTYPE_SHA256; 322 break; 323 } 324 } 325 326 return rc; 327 } 328 270 329 RTR3DECL(int) RTManifestVerifyFilesBuf(void *pvBuf, size_t cbSize, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed) 271 330 { … … 318 377 319 378 /* Check for the digest algorithm */ 320 if ( cch < 4 321 ||!( pcBuf[0] == 'S'379 if ( cch < 4 || 380 (!( pcBuf[0] == 'S' 322 381 && pcBuf[1] == 'H' 323 382 && pcBuf[2] == 'A' 324 && pcBuf[3] == '1')) 383 && pcBuf[3] == '1') 384 && 385 !( pcBuf[0] == 'S' 386 && pcBuf[1] == 'H' 387 && pcBuf[2] == 'A' 388 && pcBuf[3] == '2' 389 && pcBuf[4] == '5' 390 && pcBuf[5] == '6')) 391 ) 325 392 { 326 393 /* Digest unsupported */
Note:
See TracChangeset
for help on using the changeset viewer.