This is an archive of the discontinued LLVM Phabricator instance.

[lldb/Utility] Fix DecodeUUIDBytesFromString not to access past the input buffer
AbandonedPublic

Authored by friss on May 29 2020, 8:37 AM.

Details

Reviewers
labath
Summary

The current logig in this function reads:

while (!p.empty()) {
   if (isxdigit(p[0]) && isxdigit(p[1])) {

if p is of size one when entering the loop, the second isxdigit
will access past the end of the buffer. This patch takes the simplest
approach of verifying that the buffer is at least of size 2.

Diff Detail

Event Timeline

friss created this revision.May 29 2020, 8:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2020, 8:37 AM
friss added a comment.May 29 2020, 8:39 AM

I would have committed this right away if it weren't for the slight change in behavior I wanted to point out. With this patch, if an input string ends with a -, it won't be consumed anymore. I suppose it doesn't matter.

labath accepted this revision.Jun 1 2020, 1:34 AM

I would have committed this right away if it weren't for the slight change in behavior I wanted to point out. With this patch, if an input string ends with a -, it won't be consumed anymore. I suppose it doesn't matter.

That looks fine. A trailing - looks like someone wanted to add more bytes but then pressed return too early, so rejecting that sounds perfectly reasonable.

Since you've obviously been looking at this code lately, I've also added you the to D80755, for the mac perspective of accepting "uuid"s with different lengths.

This revision is now accepted and ready to land.Jun 1 2020, 1:34 AM
friss abandoned this revision.Jun 2 2020, 9:29 AM

Abandon in favor of D80755