Commit 81e40f3a by Matthew Malcomson Committed by Matthew Malcomson

[aarch64] Allocate space for err_str in aarch64_handle_attr_branch_protection


-fsanitize=hwaddress found a one-byte overwrite when running the
testsuite here.  aarch64_handle_attr_branch_protection allocates
`strlen(str)` bytes for an error string, which is populated by
`strcpy(..., str)` in the case where the branch protection string is
completely invalid.

Not tested -- I don't want to re-build and it seems obvious.

gcc/ChangeLog:

2019-11-05  Matthew Malcomson  <matthew.malcomson@arm.com>

	* config/aarch64/aarch64.c (aarch64_handle_attr_cpu): Allocate
	enough bytes for the NULL character.

From-SVN: r277845
parent 4330d1c4
2019-11-05 Matthew Malcomson <matthew.malcomson@arm.com>
* config/aarch64/aarch64.c (aarch64_handle_attr_cpu): Allocate
enough bytes for the NULL character.
2019-11-05 Richard Biener <rguenther@suse.de> 2019-11-05 Richard Biener <rguenther@suse.de>
PR tree-optimization/92280 PR tree-optimization/92280
...@@ -14156,7 +14156,7 @@ aarch64_handle_attr_cpu (const char *str) ...@@ -14156,7 +14156,7 @@ aarch64_handle_attr_cpu (const char *str)
static bool static bool
aarch64_handle_attr_branch_protection (const char* str) aarch64_handle_attr_branch_protection (const char* str)
{ {
char *err_str = (char *) xmalloc (strlen (str)); char *err_str = (char *) xmalloc (strlen (str) + 1);
enum aarch64_parse_opt_result res = aarch64_parse_branch_protection (str, enum aarch64_parse_opt_result res = aarch64_parse_branch_protection (str,
&err_str); &err_str);
bool success = false; bool success = false;
......
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