From 1b70729f701d8533f926fca8e2df40b2819fbc31 Mon Sep 17 00:00:00 2001 From: Rafael Avila de Espindola Date: Mon, 16 Nov 2009 20:25:42 +0000 Subject: [PATCH] lto-elf.c (lto_elf_file_open): Use strtoll to parse the offset. 2009-11-16 Rafael Avila de Espindola * lto-elf.c (lto_elf_file_open): Use strtoll to parse the offset. From-SVN: r154215 --- gcc/lto/ChangeLog | 4 ++++ gcc/lto/lto-elf.c | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 963319980a0c..b37c549fde8c 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -1,3 +1,7 @@ +2009-11-16 Rafael Avila de Espindola + + * lto-elf.c (lto_elf_file_open): Use strtoll to parse the offset. + 2009-11-14 Jan Hubicka * lto.c (read_cgraph_and_symbols): Set also ipa_transforms_to_apply. diff --git a/gcc/lto/lto-elf.c b/gcc/lto/lto-elf.c index ee587f7a7502..bc8e137ccc24 100644 --- a/gcc/lto/lto-elf.c +++ b/gcc/lto/lto-elf.c @@ -540,7 +540,7 @@ lto_file * lto_elf_file_open (const char *filename, bool writable) { lto_elf_file *elf_file; - lto_file *result; + lto_file *result = NULL; off_t offset; const char *offset_p; char *fname; @@ -553,13 +553,17 @@ lto_elf_file_open (const char *filename, bool writable) } else { - int64_t t; fname = (char *) xmalloc (offset_p - filename + 1); memcpy (fname, filename, offset_p - filename); fname[offset_p - filename] = '\0'; offset_p++; - sscanf(offset_p, "%" PRId64 , &t); - offset = t; + errno = 0; + offset = strtoll (offset_p, NULL, 10); + if (errno != 0) + { + error ("could not parse offset %s", offset_p); + goto fail; + } /* elf_rand expects the offset to point to the ar header, not the object itself. Subtract the size of the ar header (60 bytes). We don't uses sizeof (struct ar_hd) to avoid including ar.h */ @@ -631,7 +635,8 @@ lto_elf_file_open (const char *filename, bool writable) return result; fail: - lto_elf_file_close (result); + if (result) + lto_elf_file_close (result); return NULL; }