Page MenuHomeFreeBSD

ngctl: Check hook name length
ClosedPublic

Authored by des on Thu, Feb 12, 12:36 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Feb 14, 6:27 PM
Unknown Object (File)
Fri, Feb 13, 2:38 AM
Unknown Object (File)
Fri, Feb 13, 2:05 AM
Unknown Object (File)
Fri, Feb 13, 2:05 AM
Unknown Object (File)
Fri, Feb 13, 1:09 AM
Unknown Object (File)
Thu, Feb 12, 9:53 PM
Unknown Object (File)
Thu, Feb 12, 5:12 PM
Unknown Object (File)
Thu, Feb 12, 3:15 PM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.Thu, Feb 12, 12:36 AM
markj added inline comments.
usr.sbin/ngctl/write.c
77

Better would be to write sizeof(sag->sg_data) instead of NG_HOOKSIZ IMO.

79

Might as well explain why it's invalid.

This revision is now accepted and ready to land.Thu, Feb 12, 2:36 PM
des marked 2 inline comments as done.Thu, Feb 12, 3:52 PM
des added inline comments.
usr.sbin/ngctl/write.c
77

No, because sag->sg_data has the wrong size.

des marked an inline comment as done.

better error message

This revision now requires review to proceed.Thu, Feb 12, 3:53 PM
usr.sbin/ngctl/write.c
77

sag->sg_data is defined as char sg_data[32] and NG_HOOKSIZ is 32 as well. What am I missing?

des marked an inline comment as done.Thu, Feb 12, 7:00 PM
des added inline comments.
usr.sbin/ngctl/write.c
77

That's a recent change which can't be MFCed. It's also a parallel construction: a hardcoded literal which has been chosen to match to the current value of NG_NODESIZ, but deliberately not NG_NODESIZ itself. And last but not least, I don't feel comfortable assuming that NG_HOOKSIZ is equal to NG_NODESIZ.

des marked an inline comment as done.Thu, Feb 12, 7:01 PM
markj added inline comments.
usr.sbin/ngctl/write.c
77

Then you might consider adding something like _Static_assert(NG_HOOKSIZ <= sizeof(sag->sg_data)) or _Static_assert(NG_HOOKSIZ <= sizeof(sagbuf)).

This revision is now accepted and ready to land.Fri, Feb 13, 3:25 PM
This revision was automatically updated to reflect the committed changes.