You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Summary:
This moves to more secure string operations for the `controller_set_text` and `controller_print` functions. Previously, `controller_print` would overrun the buffer when printing a string smaller than the maximum allowable length, and a string longer than CONTROLLER_MAX_COLS could be written into the smaller destination buffer in `controller_set_text`.
#### Motivation:
This will prevent buffer overrun and its associated issues in the controller printing functions.
##### References (optional):
Closes#97.
#### Test Plan:
- [x] Compiles
- [x] Call `controller_set_text` with a string longer than `CONTROLLER_MAX_COLS`
- [x] Call `controller_print` with a string that is shorter than `CONTROLLER_MAX_COLS`
#### Commits:
* Improve controller printing safety
* fix pointer reference
* use strndup instead of strlcpy
strlcpy is nonstandard, even by our standards (lol)
Could vasprintf() return buffer that is smaller than 16 bytes?
It is, probably, a good idea to check return value vasprintf() which is guaranteed to allocate only number of printed bytes + 1.
pros/src/devices/controller.c
Line 248 in bc0fa3e
The text was updated successfully, but these errors were encountered: