]> gcc.gnu.org Git - gcc.git/commit
AArch64: Fix hwasan failure in readline.
authorTamar Christina <tamar.christina@arm.com>
Mon, 3 Aug 2020 11:03:17 +0000 (12:03 +0100)
committerJakub Jelinek <jakub@redhat.com>
Thu, 17 Sep 2020 15:40:49 +0000 (17:40 +0200)
commit97073a931a7b5659a51f9988ccb3f15a555f5f0a
treeb4eae32f5629b8a735e39f1522e2078aabe5b295
parent6af59c313bdbe515c0a89a1498d18d2ab1cf0e85
AArch64: Fix hwasan failure in readline.

My previous fix added an unchecked call to fgets in the new function readline.
fgets can fail when there's an error reading the file in which case it returns
NULL.  It also returns NULL when the next character is EOF.

The EOF case is already covered by the existing code but the error case isn't.
This fixes it by returning the empty string on error.

Also I now use strnlen instead of strlen to make sure we never read outside the
buffer.

This was flagged by Matthew Malcomson during his hwasan work.

gcc/ChangeLog:

* config/aarch64/driver-aarch64.c (readline): Check return value fgets.

(cherry picked from commit 341573406b392f4d57e052ce22f80e85a7c479e9)
gcc/config/aarch64/driver-aarch64.c
This page took 0.061106 seconds and 6 git commands to generate.