diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 963319980a0..b37c549fde8 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 ee587f7a750..bc8e137ccc2 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; }