Page MenuHomeFreeBSD

Always null-terminate CAM periph_name and dev_name
ClosedPublic

Authored by asomers on Nov 22 2017, 6:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 25, 3:28 PM
Unknown Object (File)
Wed, Apr 24, 5:22 PM
Unknown Object (File)
Tue, Apr 23, 11:06 PM
Unknown Object (File)
Tue, Apr 23, 12:59 PM
Unknown Object (File)
Thu, Apr 18, 1:37 PM
Unknown Object (File)
Tue, Apr 9, 4:44 AM
Unknown Object (File)
Mar 23 2024, 1:09 AM
Unknown Object (File)
Jan 11 2024, 9:48 PM
Subscribers

Details

Summary

Always null-terminate CAM periph_name and dev_name

Reported by: Coverity
CID: 1010039, 1010040, 1010041, 1010043

Test Plan

camlib tests, basic camcontrol commands

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I didn't tag all the places that need it, but I'd be tempted to go with sizeof(dst) rather than a #define that may or may not be right and requires extra brain power to go check for each case.

Even w/o it, the change is an improvement.

sys/cam/cam_xpt.c
689 ↗(On Diff #35606)

this actually did NUL terminate. It wasn't safe though. I'd make a note of the migration from the unsafe / hard-to-user interfaces to the strl interfaces in the commit.

690 ↗(On Diff #35606)

the traditional thing here is 'sizeof(ccb->cgdl.periph_name)' instead of some random #define that may be right or wrong. We know the CCBs preallocate so we don't have to worry about the pointer issue.

1760 ↗(On Diff #35606)

Same sizeof comment for this argument.

This revision is now accepted and ready to land.Nov 22 2017, 6:26 PM

Looks good, assuming you put sizeof() in there.

sys/cam/cam_xpt.c
690 ↗(On Diff #35606)

I agree with the sizeof() thing. That would be the better way to do it.

This revision was automatically updated to reflect the committed changes.