scsi_cname is unsafe
scsi_cname uses a global buffer (without any locking etc.) and returns a pointer to it if the input command cannot be decoded.
Probably it should be changed to just return a fixed value, instead of a variable string.
Arguably the callers could do something better here, or we could provide scratch space from the caller.
Updated by Garrett D'Amore 5 months ago
The only in-gate consumer of this API is scsa2usb, which also emits the code byte.
So there is no need to do a variable formatted string. We can just make the string a fixed string without using a scratch buffer at all. This does not violate the documented behavior, and it is suspected that there may not be any other callers for this function outside of scsa2usb anywhere.
Updated by Electric Monk 5 months ago
- Status changed from In Progress to Closed
- % Done changed from 90 to 100
commit f81518d2d2ef63a80422631582fa82f0f956a850 Author: Garrett D'Amore <firstname.lastname@example.org> Date: 2022-07-14T20:33:31.000Z 14797 scsi_cname is unsafe Reviewed by: Toomas Soome <email@example.com> Reviewed by: Igor Kozhukhov <firstname.lastname@example.org> Approved by: Dan McDonald <email@example.com>