Expand filename for coredumps correctly. Fixes #174908. Also take

the opportunity to remove some sprintf-ing into a fixed-sized buffer.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8774
This commit is contained in:
Julian Seward 2008-11-17 12:45:58 +00:00
parent 3b60492dc1
commit 69fcffda22

View File

@ -286,7 +286,7 @@ static void fill_xfpu(const ThreadState *tst, vki_elf_fpxregset_t *xfpu)
static
void make_elf_coredump(ThreadId tid, const vki_siginfo_t *si, UInt max_size)
{
Char buf[1000];
Char* buf = NULL;
Char *basename = "vgcore";
Char *coreext = "";
Int seq = 0;
@ -306,9 +306,18 @@ void make_elf_coredump(ThreadId tid, const vki_siginfo_t *si, UInt max_size)
if (VG_(clo_log_name) != NULL) {
coreext = ".core";
basename = VG_(clo_log_name);
basename = VG_(expand_file_name)(
"--log-file (while creating core filename)",
VG_(clo_log_name));
}
vg_assert(coreext);
vg_assert(basename);
buf = VG_(malloc)( "coredump-elf.mec.1",
VG_(strlen)(coreext) + VG_(strlen)(basename)
+ 100/*for the two %ds. */ );
vg_assert(buf);
for(;;) {
SysRes sres;