pd-mapper: Null terminate firmware_value string

Null terminate firmware_value string to prevent
strlen() read past the end of buffer error on AOSP.

Otherwise pd-mapper will crash:
  console:/ # pd-mapper
  FORTIFY: strlen: detected read past end of buffer
  Aborted
  134|console:/ #

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
This commit is contained in:
Amit Pundir
2020-04-14 22:45:05 +05:30
committed by Bjorn Andersson
parent d7fe25fa6e
commit aaed6554da

View File

@@ -242,6 +242,8 @@ static int pd_enumerate_jsons(struct assoc *json_set)
continue;
}
firmware_value[n] = '\0';
if (strlen(FIRMWARE_BASE) + strlen(firmware_value) + 1 > sizeof(path))
continue;