summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Dooley <dooleyc@google.com>2023-11-09 07:13:38 +0000
committerTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2023-11-18 00:04:54 +0000
commitc4a71452049c4a25ad6b7eb3ad8a5f4ac7f5af81 (patch)
tree8950cdb87d9c024432c1f33faa937a7741e9ce68
parentd6e1dfd22d29969a9bb3d0a15a5e54e429b81f07 (diff)
downloadaoc-c4a71452049c4a25ad6b7eb3ad8a5f4ac7f5af81.tar.gz
Fix the reason string when triggered from ALSA
The NULL termination was wrong when triggered from ALSA, due to trigger_watchdog passing strlen (without NULL) as the count. The explicit NULL termination here would overwrite the last character, but strscpy is supposed to use the full size of the destination buffer and handle NULL termination itself. Bug: 309902598 Change-Id: I9cf91660a5fd85fdcc2589dafa5f3c8af4e0fdb8 Signed-off-by: Craig Dooley <dooleyc@google.com>
-rw-r--r--aoc.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/aoc.c b/aoc.c
index 21e0cf7..868856b 100644
--- a/aoc.c
+++ b/aoc.c
@@ -938,15 +938,13 @@ static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
{
struct aoc_prvdata *prvdata = dev_get_drvdata(dev);
char reason_str[MAX_RESET_REASON_STRING_LEN + 1];
- size_t reason_str_len = min(MAX_RESET_REASON_STRING_LEN, count);
if (aoc_state != AOC_STATE_ONLINE || work_busy(&prvdata->watchdog_work)) {
dev_err(dev, "Reset requested while AoC is not online");
return -ENODEV;
}
- strscpy(reason_str, buf, reason_str_len);
- reason_str[reason_str_len] = '\0';
+ strscpy(reason_str, buf, sizeof(reason_str));
dev_err(dev, "Reset requested from userspace, reason: %s", reason_str);
if (prvdata->no_ap_resets) {