From 87c85b7e23f3d87b0c8a8826e3ebc867fca7e7ae Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Tue, 26 Jan 2016 23:43:37 +0000 Subject: Fix identify_magic() to check that a file that starts with MH_MAGIC is at least as big as the mach header to be identified as a Mach-O file and make sure smaller files are not identified as a Mach-O files but as unknown files. Also fix identify_magic() so it looks at all 4 bytes of the filetype field when determining the type of the Mach-O file. Then fix the macho-invalid-header test case to check that it is an unknown file and make sure it does not get the error for object_error::parse_failed. And also update the unit tests. llvm-svn: 258883 --- llvm/test/Object/macho-invalid.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/test/Object') diff --git a/llvm/test/Object/macho-invalid.test b/llvm/test/Object/macho-invalid.test index 77a3944bdd6..cbd378a0332 100644 --- a/llvm/test/Object/macho-invalid.test +++ b/llvm/test/Object/macho-invalid.test @@ -56,7 +56,8 @@ RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC-pax %s INVALID-SECTION-IDX-SYMBOL-SEC-pax: 0000000100000000 0f 42 0010 00000065 __mh_execute_header RUN: not llvm-objdump -private-headers %p/Inputs/macho-invalid-header 2>&1 | FileCheck -check-prefix INVALID-HEADER %s -INVALID-HEADER: Invalid data was encountered while parsing the file +INVALID-HEADER: The file was not recognized as a valid object file. +NOT-INVALID-HEADER: Invalid data was encountered while parsing the file. RUN: not llvm-objdump -private-headers %p/Inputs/macho64-invalid-incomplete-segment-load-command 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC %s INCOMPLETE-SEGMENT-LOADC: Invalid data was encountered while parsing the file -- cgit v1.2.3