]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Expand filename for coredumps correctly. Fixes #174908. Also take
authorJulian Seward <jseward@acm.org>
Mon, 17 Nov 2008 12:45:58 +0000 (12:45 +0000)
committerJulian Seward <jseward@acm.org>
Mon, 17 Nov 2008 12:45:58 +0000 (12:45 +0000)
the opportunity to remove some sprintf-ing into a fixed-sized buffer.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8774

coregrind/m_coredump/coredump-elf.c

index f740b9de998885b81c332d9337f998ba50d1a8e9..7fba755e96415fb8432c0df5371328d018d98a67 100644 (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;