Commit 1b70729f by Rafael Avila de Espindola Committed by Rafael Espindola

lto-elf.c (lto_elf_file_open): Use strtoll to parse the offset.

2009-11-16  Rafael Avila de Espindola  <espindola@google.com>

	* lto-elf.c (lto_elf_file_open): Use strtoll to parse the offset.

From-SVN: r154215
parent efd0b0d3
2009-11-16 Rafael Avila de Espindola <espindola@google.com>
* lto-elf.c (lto_elf_file_open): Use strtoll to parse the offset.
2009-11-14 Jan Hubicka <jh@suse.cz> 2009-11-14 Jan Hubicka <jh@suse.cz>
* lto.c (read_cgraph_and_symbols): Set also ipa_transforms_to_apply. * lto.c (read_cgraph_and_symbols): Set also ipa_transforms_to_apply.
......
...@@ -540,7 +540,7 @@ lto_file * ...@@ -540,7 +540,7 @@ lto_file *
lto_elf_file_open (const char *filename, bool writable) lto_elf_file_open (const char *filename, bool writable)
{ {
lto_elf_file *elf_file; lto_elf_file *elf_file;
lto_file *result; lto_file *result = NULL;
off_t offset; off_t offset;
const char *offset_p; const char *offset_p;
char *fname; char *fname;
...@@ -553,13 +553,17 @@ lto_elf_file_open (const char *filename, bool writable) ...@@ -553,13 +553,17 @@ lto_elf_file_open (const char *filename, bool writable)
} }
else else
{ {
int64_t t;
fname = (char *) xmalloc (offset_p - filename + 1); fname = (char *) xmalloc (offset_p - filename + 1);
memcpy (fname, filename, offset_p - filename); memcpy (fname, filename, offset_p - filename);
fname[offset_p - filename] = '\0'; fname[offset_p - filename] = '\0';
offset_p++; offset_p++;
sscanf(offset_p, "%" PRId64 , &t); errno = 0;
offset = t; 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 /* elf_rand expects the offset to point to the ar header, not the
object itself. Subtract the size of the ar header (60 bytes). object itself. Subtract the size of the ar header (60 bytes).
We don't uses sizeof (struct ar_hd) to avoid including ar.h */ 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) ...@@ -631,7 +635,8 @@ lto_elf_file_open (const char *filename, bool writable)
return result; return result;
fail: fail:
lto_elf_file_close (result); if (result)
lto_elf_file_close (result);
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment