From 651c61c3cef123d70ec3582d53b58526a8cadcf7 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 8 Sep 2020 12:51:07 -0700 Subject: [PATCH] libbacktrace: only match magic number at start of line libbacktrace/ChangeLog: PR libbacktrace/96971 * filetype.awk: Only match magic number at start of line. --- libbacktrace/filetype.awk | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libbacktrace/filetype.awk b/libbacktrace/filetype.awk index 14d91581f7e..1eefa7e72f0 100644 --- a/libbacktrace/filetype.awk +++ b/libbacktrace/filetype.awk @@ -1,13 +1,13 @@ # An awk script to determine the type of a file. -/\177ELF\001/ { if (NR == 1) { print "elf32"; exit } } -/\177ELF\002/ { if (NR == 1) { print "elf64"; exit } } -/\114\001/ { if (NR == 1) { print "pecoff"; exit } } -/\144\206/ { if (NR == 1) { print "pecoff"; exit } } -/\001\337/ { if (NR == 1) { print "xcoff32"; exit } } -/\001\367/ { if (NR == 1) { print "xcoff64"; exit } } -/\376\355\372\316/ { if (NR == 1) { print "macho"; exit } } -/\316\372\355\376/ { if (NR == 1) { print "macho"; exit } } -/\376\355\372\317/ { if (NR == 1) { print "macho"; exit } } -/\317\372\355\376/ { if (NR == 1) { print "macho"; exit } } -/\312\376\272\276/ { if (NR == 1) { print "macho"; exit } } -/\276\272\376\312/ { if (NR == 1) { print "macho"; exit } } +/^\177ELF\001/ { if (NR == 1) { print "elf32"; exit } } +/^\177ELF\002/ { if (NR == 1) { print "elf64"; exit } } +/^\114\001/ { if (NR == 1) { print "pecoff"; exit } } +/^\144\206/ { if (NR == 1) { print "pecoff"; exit } } +/^\001\337/ { if (NR == 1) { print "xcoff32"; exit } } +/^\001\367/ { if (NR == 1) { print "xcoff64"; exit } } +/^\376\355\372\316/ { if (NR == 1) { print "macho"; exit } } +/^\316\372\355\376/ { if (NR == 1) { print "macho"; exit } } +/^\376\355\372\317/ { if (NR == 1) { print "macho"; exit } } +/^\317\372\355\376/ { if (NR == 1) { print "macho"; exit } } +/^\312\376\272\276/ { if (NR == 1) { print "macho"; exit } } +/^\276\272\376\312/ { if (NR == 1) { print "macho"; exit } }