MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / HandleShiftOutOfBounds

Function HandleShiftOutOfBounds

Library/OcGuardLib/Ubsan.c:469–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467}
468
469static void
470HandleShiftOutOfBounds(bool isFatal, struct CShiftOutOfBoundsData *pData, unsigned long ulLHS, unsigned long ulRHS)
471{
472 char szLocation[LOCATION_MAXLEN];
473 char szLHS[NUMBER_MAXLEN];
474 char szRHS[NUMBER_MAXLEN];
475
476 ASSERT(pData);
477
478 if (isAlreadyReported(&pData->mLocation))
479 return;
480
481 DeserializeLocation(szLocation, LOCATION_MAXLEN, &pData->mLocation);
482 DeserializeNumber(szLocation, szLHS, NUMBER_MAXLEN, pData->mLHSType, ulLHS);
483 DeserializeNumber(szLocation, szRHS, NUMBER_MAXLEN, pData->mRHSType, ulRHS);
484
485 if (isNegativeNumber(szLocation, pData->mRHSType, ulRHS))
486 Report(isFatal, "UBSan: Undefined Behavior in %s, shift exponent %s is negative\n",
487 szLocation, szRHS);
488 else if (isShiftExponentTooLarge(szLocation, pData->mRHSType, ulRHS, zDeserializeTypeWidth(pData->mLHSType)))
489 Report(isFatal, "UBSan: Undefined Behavior in %s, shift exponent %s is too large for %zu-bit type %s\n",
490 szLocation, szRHS, zDeserializeTypeWidth(pData->mLHSType), pData->mLHSType->mTypeName);
491 else if (isNegativeNumber(szLocation, pData->mLHSType, ulLHS))
492 Report(isFatal, "UBSan: Undefined Behavior in %s, left shift of negative value %s\n",
493 szLocation, szLHS);
494 else
495 Report(isFatal, "UBSan: Undefined Behavior in %s, left shift of %s by %s places cannot be represented in type %s\n",
496 szLocation, szLHS, szRHS, pData->mLHSType->mTypeName);
497}
498
499static void
500HandleImplicitConversion(bool isFatal, struct CImplicitConversionData *pData, unsigned long ulFrom, unsigned long ulTo)

Calls 7

isAlreadyReportedFunction · 0.85
DeserializeLocationFunction · 0.85
DeserializeNumberFunction · 0.85
isNegativeNumberFunction · 0.85
isShiftExponentTooLargeFunction · 0.85
zDeserializeTypeWidthFunction · 0.85
ReportFunction · 0.70

Tested by

no test coverage detected