This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix off-by-one error in the AppleObjCRuntimeV2 utility function
ClosedPublic

Authored by JDevlieghere on Jun 22 2022, 1:44 PM.

Details

Summary

Fix an off-by-one error in the utility function used to extract the dynamic class info. This resulted in a buffer overflow in the inferior which interrupted our utility function.

Diff Detail

Event Timeline

JDevlieghere created this revision.Jun 22 2022, 1:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2022, 1:44 PM
JDevlieghere requested review of this revision.Jun 22 2022, 1:44 PM
aprantl accepted this revision.Jun 22 2022, 1:47 PM

I'm curious now why there is both count and max_class_infos and if the second is workaround for this bug? Anyway, this *looks* plausible!

This revision is now accepted and ready to land.Jun 22 2022, 1:47 PM

I'm curious now why there is both count and max_class_infos and if the second is workaround for this bug? Anyway, this *looks* plausible!

count is the actual value reported by the runtime. max_class_infos is a monotonically increasing number that allows us to detect that new classes have been instantiated. The latter is also used to allocate enough space. The guarantee from the runtime is that count < max_class_infos.

Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2022, 1:57 PM