This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Avoid another non zero terminated string constant
- From: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Richard Biener <rguenther at suse dot de>
- Date: Sun, 29 Jul 2018 08:13:26 +0000
- Subject: [PATCH] Avoid another non zero terminated string constant
Hi!
This fixes another not NUL terminated string literal that is created
in tree-ssa-forwprop.c at simplify_builtin_call.
src_buf is set up to contain a NUL at src_buf[src_len], thus use src_len + 1
as length parameter to build_string_literal. All other uses of
build_string_literal do it right, as far as I can see.
Bootstrapped and reg-tested on x86_64-pc-linux-gnu.
Is it OK for trunk?
Thanks
Bernd.
2018-07-29 Bernd Edlinger <bernd.edlinger@hotmail.de>
* tree-ssa-forwprop.c (simplify_builtin_call): Don't create a not NUL
terminated string literal.
Index: gcc/tree-ssa-forwprop.c
===================================================================
--- gcc/tree-ssa-forwprop.c (revision 263045)
+++ gcc/tree-ssa-forwprop.c (working copy)
@@ -1391,7 +1391,7 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p
src_buf, ptr1_align, false))
break;
- new_str_cst = build_string_literal (src_len, src_buf);
+ new_str_cst = build_string_literal (src_len + 1, src_buf);
if (callee1)
{
/* If STMT1 is a mem{,p}cpy call, adjust it and remove