Skip to content

Commit 34f4561

Browse files
author
Yury Gribov
committedOct 20, 2015
[ubsan] Fix looksLikeFloatCastOverflowDataV1 heuristic to work if one of the types is unknown.
Differential revision: http://reviews.llvm.org/D13775 llvm-svn: 250806
1 parent 100f40c commit 34f4561

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

‎compiler-rt/lib/ubsan/ubsan_handlers.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,14 @@ static bool looksLikeFloatCastOverflowDataV1(void *Data) {
314314
sizeof(FilenameOrTypeDescriptor));
315315

316316
// Heuristic: For float_cast_overflow, the TypeKind will be either TK_Integer
317-
// (0x0) or TK_Float (0x1). Adding both bytes will be 0 or 1 (for BE or LE).
318-
// If it were a filename, adding two printable characters will not yield such
319-
// a value.
317+
// (0x0), TK_Float (0x1) or TK_Unknown (0xff). If both types are known,
318+
// adding both bytes will be 0 or 1 (for BE or LE). If it were a filename,
319+
// adding two printable characters will not yield such a value. Otherwise,
320+
// if one of them is 0xff, this is most likely TK_Unknown type descriptor.
320321
u16 MaybeFromTypeKind =
321322
FilenameOrTypeDescriptor[0] + FilenameOrTypeDescriptor[1];
322-
return MaybeFromTypeKind < 2;
323+
return MaybeFromTypeKind < 2 || FilenameOrTypeDescriptor[0] == 0xff ||
324+
FilenameOrTypeDescriptor[1] == 0xff;
323325
}
324326

325327
static void handleFloatCastOverflow(void *DataPtr, ValueHandle From,

0 commit comments

Comments
 (0)
Please sign in to comment.