Re: [PATCH] egalax_ts_serial: Fix potential buffer overflow

From: Böszörményi Zoltán
Date: Mon Dec 04 2023 - 01:41:00 EST


2023. 12. 03. 19:35 keltezéssel, Dmitry Torokhov írta:
Hi Zoltán,

On Sun, Dec 03, 2023 at 10:06:00AM +0100, Zoltán Böszörményi wrote:
@@ -42,7 +42,7 @@ struct egalax {
struct serio *serio;
int idx;
u8 data[EGALAX_FORMAT_MAX_LENGTH];
- char phys[32];
+ char phys[NAME_MAX];
This simply wastes 200+ bytes for no good reason. It is perfectly fine
to truncate phys string (which does not happen in practice).

Okay, I modified the phys[] array to just be 40 bytes.
That's not that wasteful and still avoids the warning.

I noticed that other TS drivers emit the same warning.


If you feel strongly about it then maybe use devm_kasprintf() to
allocate the needed buffer.

Thanks.