3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 09:39:25 +01:00

display: use l_strlcpy to avoid potential overflow

If 'entry' exceeds the length of 'line' we could overflow. Instead
use l_strlcpy and pass in the remaining amount of data left in
the buffer.
This commit is contained in:
James Prestwood 2021-02-08 12:19:54 -08:00 committed by Denis Kenzior
parent 8139b6bad7
commit 3f1cd5a596

View File

@ -419,7 +419,7 @@ static void display_completion_matches(char **matches, int num_matches,
}
entry = l_strdup_printf("%-*s ", max_length, matches[index]);
strcpy(&line[line_used], entry);
l_strlcpy(&line[line_used], entry, sizeof(line) - line_used);
l_free(entry);
line_used += max_length + 1;