On Tuesday 19 May 2015 20:23:37 Maros Zatko wrote:
---
src/filearch.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/filearch.c b/src/filearch.c
index 8fb1acf..ce9d0a1 100644
--- a/src/filearch.c
+++ b/src/filearch.c
@@ -59,14 +59,14 @@ cleanup_magic_t_free (void *ptr)
# endif
COMPILE_REGEXP (re_file_elf,
- "ELF.*(?:executable|shared object|relocatable), (.+?),", 0)
-COMPILE_REGEXP (re_elf_ppc64, "64.*PowerPC", 0)
+ "ELF.*(MSB|LSB).*(?:executable|shared object|relocatable),
(.+?),", 0)
+COMPILE_REGEXP (re_elf_ppc64, ".*64.*PowerPC", 0)
/* Convert output from 'file' command on ELF files to the canonical
* architecture string. Caller must free the result.
*/
static char *
-canonical_elf_arch (guestfs_h *g, const char *elf_arch)
+canonical_elf_arch (guestfs_h *g, const char *endianness, const char *elf_arch)
{
const char *r;
char *ret;
@@ -85,8 +85,12 @@ canonical_elf_arch (guestfs_h *g, const char *elf_arch)
r = "sparc64";
else if (strstr (elf_arch, "IA-64"))
r = "ia64";
- else if (match (g, elf_arch, re_elf_ppc64))
- r = "ppc64";
+ else if (match (g, elf_arch, re_elf_ppc64)) {
+ if (strstr (endianness, "MSB"))
+ r = "ppc64";
+ else if (strstr (endianness, "LSB"))
+ r = "ppc64le";
Can you please add an else branch signalling with error() the unknown
endianness string and returning NULL? Just a small safe guard.
--
Pino Toscano