Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input: edt-ft5x06: Correct prefix length in snprintf #5798

Merged
merged 1 commit into from
Dec 18, 2023

Conversation

6by9
Copy link
Contributor

@6by9 6by9 commented Dec 18, 2023

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.

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 <dave.stevenson@raspberrypi.com>
@JamesH65
Copy link
Contributor

The string being written into doesn't seem to have space for the terminator if both the prefix and name are the maximum length they can be. If I read it right.

@6by9
Copy link
Contributor Author

6by9 commented Dec 18, 2023

The string being written into doesn't seem to have space for the terminator if both the prefix and name are the maximum length they can be. If I read it right.

snprintf(model_name, EDT_NAME_PREFIX_LEN + 1, "%s ", dev_name(&client->dev)); will print max EDT_NAME_PREFIX_LEN chars and the NULL.
model_name += strlen(model_name); will move forward by max EDT_NAME_PREFIX_LEN chars.

Therefore snprintf(model_name, EDT_NAME_LEN, "EP0%i%i0M09", rdbuf[0] >> 4, rdbuf[0] & 0x0F); will move forward by max EDT_NAME_LEN chars (including the NULL), so we don't run off the end of char name[EDT_NAME_PREFIX_LEN + EDT_NAME_LEN];

@pelwell pelwell merged commit e0ecfaf into raspberrypi:rpi-6.1.y Dec 18, 2023
12 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Dec 21, 2023
kernel: ARM: dts: bcm2712-rpi-5-b: Allow RTC to be disabled
See: raspberrypi/linux#5803

kernel: Improve Pi 5 I2C bus timing
See: raspberrypi/linux#5802

kernel: input: edt-ft5x06: Correct prefix length in snprintf
See: raspberrypi/linux#5798

kernel: Allow IMX477 and IMX296 to be always on, to simplify multi-camera sync
See: raspberrypi/linux#5774
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Dec 21, 2023
kernel: ARM: dts: bcm2712-rpi-5-b: Allow RTC to be disabled
See: raspberrypi/linux#5803

kernel: Improve Pi 5 I2C bus timing
See: raspberrypi/linux#5802

kernel: input: edt-ft5x06: Correct prefix length in snprintf
See: raspberrypi/linux#5798

kernel: Allow IMX477 and IMX296 to be always on, to simplify multi-camera sync
See: raspberrypi/linux#5774
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants