Skip to content

Commit

Permalink
input: edt-ft5x06: Correct prefix length in snprintf
Browse files Browse the repository at this point in the history
snprintf takes the length of the array that we can print into,
and has to fit the NULL terminator in there too.
Printing the prefix is generally "12-3456 " which is 8 desired
characters (the length of EDT_NAME_PREFIX_LEN) and the NULL.
The space is therefore being truncated to fit the NULL in.

Increase the length snprintf is allowed to use.

Signed-off-by: Dave Stevenson <[email protected]>
  • Loading branch information
6by9 authored and pelwell committed Dec 19, 2023
1 parent add8c28 commit cee7137
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/input/touchscreen/edt-ft5x06.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ static int edt_ft5x06_ts_identify(struct i2c_client *client,
char *model_name = tsdata->name;
char *fw_version = tsdata->fw_version;

snprintf(model_name, EDT_NAME_PREFIX_LEN, "%s ", dev_name(&client->dev));
snprintf(model_name, EDT_NAME_PREFIX_LEN + 1, "%s ", dev_name(&client->dev));
model_name += strlen(model_name);

/* see what we find if we assume it is a M06 *
Expand Down

0 comments on commit cee7137

Please sign in to comment.