public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3977] Plug possible snprintf overflow in lto-wrapper. Date: Thu, 30 Sep 2021 07:54:33 +0000 (GMT) [thread overview] Message-ID: <20210930075433.819703858C39@sourceware.org> (raw) https://gcc.gnu.org/g:f5440ac7ad535edcf143a877c3da11a41cbf2c37 commit r12-3977-gf5440ac7ad535edcf143a877c3da11a41cbf2c37 Author: Aldy Hernandez <aldyh@redhat.com> Date: Tue Sep 28 15:54:20 2021 +0200 Plug possible snprintf overflow in lto-wrapper. My upcoming improvements to the DOM threader triggered a warning in this code. It looks like the format string is ".ltrans%u.ltrans", but we're only writing a max of ".ltrans" + whatever the MAX_INT is here. Tested on x86-64 Linux. gcc/ChangeLog: * lto-wrapper.c (run_gcc): Plug snprintf overflow. Diff: --- gcc/lto-wrapper.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 903c258a03a..7b9e4883f38 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -1983,7 +1983,9 @@ cont: output_name = XOBFINISH (&env_obstack, char *); /* Adjust the dumpbase if the linker output file was seen. */ - int dumpbase_len = (strlen (dumppfx) + sizeof (DUMPBASE_SUFFIX)); + int dumpbase_len = (strlen (dumppfx) + + sizeof (DUMPBASE_SUFFIX) + + sizeof (".ltrans")); char *dumpbase = (char *) xmalloc (dumpbase_len + 1); snprintf (dumpbase, dumpbase_len, "%sltrans%u.ltrans", dumppfx, i); argv_ptr[0] = dumpbase; @@ -2009,9 +2011,11 @@ cont: } else { - char argsuffix[sizeof (DUMPBASE_SUFFIX) + 1]; + char argsuffix[sizeof (DUMPBASE_SUFFIX) + + sizeof (".ltrans_args") + 1]; if (save_temps) - snprintf (argsuffix, sizeof (DUMPBASE_SUFFIX), + snprintf (argsuffix, + sizeof (DUMPBASE_SUFFIX) + sizeof (".ltrans_args"), "ltrans%u.ltrans_args", i); fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true, save_temps ? argsuffix : NULL);
reply other threads:[~2021-09-30 7:54 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210930075433.819703858C39@sourceware.org \ --to=aldyh@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).