Page MenuHomeFreeBSD

jail_getid(3): validate jid string input

Authored by kevans on May 23 2019, 8:53 PM.



Currently, if jail_getid(3) is passed in a numeric string, it assumes that this is a jid string and passes it back converted to an int without checking that it's a valid/existing jid. This breaks consumers that might use jail_getid(3) to see if it can trivially grab a jid from a name if that name happens to be numeric but not actually the name/jid of the jail. Instead of returning -1 for the jail not existing, it'll return the int version of the input and the consumer will not fallback to trying other methods.

Pass the numeric input to jail_get(2) as the jid for validation, rather than the name.

Diff Detail

rS FreeBSD src repository - subversion
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Tested with ps and jexec, passing jail name and jid, and with numerically and non-numerically named jails. All's good :-).

This revision is now accepted and ready to land.May 23 2019, 10:46 PM
This revision was automatically updated to reflect the committed changes.