Changeset 104829 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- May 31, 2024 3:17:46 PM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/efi/efisignaturedb.cpp
r98103 r104829 48 48 #include <iprt/mem.h> 49 49 #include <iprt/sg.h> 50 #include <iprt/uuid.h> 50 51 51 52 #include <iprt/formats/efi-signature.h> … … 158 159 159 160 /** 160 * Validates the given signature l sit header.161 * Validates the given signature list header. 161 162 * 162 163 * @returns Flag whether the list header is considered valid. … … 266 267 267 268 /** 268 * Variant for written a list of signatures where each signature gets its own signature list header 269 * De-duplicate a signature database. 270 * 271 * @returns IPRT status code. 272 * @param pThis The signature database instance. 273 */ 274 static int rtEfiSigDbDeduplicate(PRTEFISIGDBINT pThis) 275 { 276 /** @todo This currently deduplicates list nodes as a whole, not looking into signature lists. 277 * Good enough for the X.509 certificates which matter most to eliminate multiple enrollments. */ 278 for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aLstSigTypes); i++) 279 { 280 PRTEFISIGNATURE pIt, pItNext; 281 RTListForEachSafe(&pThis->aLstSigTypes[i], pIt, pItNext, RTEFISIGNATURE, NdLst) 282 { 283 PRTEFISIGNATURE pIt2; 284 RTListForEach(&pThis->aLstSigTypes[i], pIt2, RTEFISIGNATURE, NdLst) 285 { 286 /* Compare up to element before pIt. */ 287 if (pIt == pIt2) 288 break; 289 if ( pIt->cbSignature == pIt2->cbSignature 290 && !RTUuidCompare(&pIt->UuidOwner, &pIt2->UuidOwner) 291 && !memcmp(&pIt->abSignature[0], &pIt2->abSignature[0], pIt->cbSignature)) 292 { 293 RTListNodeRemove(&pIt->NdLst); 294 RTMemFree(pIt); 295 break; 296 } 297 } 298 } 299 } 300 301 return VINF_SUCCESS; 302 } 303 304 305 /** 306 * Variant for writing a list of signatures where each signature gets its own signature list header 269 307 * (for types where each signature can differ in size like X.509). 270 308 * … … 456 494 } 457 495 496 int rc2 = rtEfiSigDbDeduplicate(pThis); 497 if (RT_SUCCESS(rc)) 498 rc = rc2; 499 458 500 return rc; 459 501 } … … 492 534 } 493 535 536 int rc2 = rtEfiSigDbDeduplicate(pThis); 537 if (RT_SUCCESS(rc)) 538 rc = rc2; 539 494 540 return rc; 495 541 } … … 523 569 rc = VERR_INVALID_PARAMETER; 524 570 571 int rc2 = rtEfiSigDbDeduplicate(pThis); 572 if (RT_SUCCESS(rc)) 573 rc = rc2; 574 525 575 return rc; 526 576 }
Note:
See TracChangeset
for help on using the changeset viewer.