[Native Lint] Destination buffer is not null terminated explicitly. (strncpy)

Summary: As a good practice, let's make sure that the "kill_desc" buffer is always null-terminated, even if its size changes in the future.

Test: Successful build on master.

Change-Id: I68a0dc346ea26126a1581994f9c508980a6ac408
Signed-off-by: Abdelrahman Daim <adaim@meta.com>
This commit is contained in:
Abdelrahman Daim 2024-09-25 09:04:56 -07:00
parent 1683221f0d
commit 96f09654e4
1 changed files with 2 additions and 0 deletions

View File

@ -2877,6 +2877,7 @@ update_watermarks:
min_score_adj = pressure_after_kill_min_score;
kill_reason = PRESSURE_AFTER_KILL;
strncpy(kill_desc, "min watermark is breached even after kill", sizeof(kill_desc));
kill_desc[sizeof(kill_desc) - 1] = '\0';
} else if (level == VMPRESS_LEVEL_CRITICAL && events != 0) {
/*
* Device is too busy reclaiming memory which might lead to ANR.
@ -2885,6 +2886,7 @@ update_watermarks:
*/
kill_reason = NOT_RESPONDING;
strncpy(kill_desc, "device is not responding", sizeof(kill_desc));
kill_desc[sizeof(kill_desc) - 1] = '\0';
} else if (swap_is_low && thrashing > thrashing_limit_pct) {
/* Page cache is thrashing while swap is low */
kill_reason = LOW_SWAP_AND_THRASHING;