Years and years ago, there was a spreadsheet posted here that allowed one to pick the right length hood for a lens depending on the following
The diameter of the hood,
The diameter of the front element (usually maximum aperture x focal length)
How far the front element is set back from the filter threads.
The body format. Full frame or APSC
With these 4 parameters you can determine the maximum length before vignetting.
Check out the two links in this post
Optimal Lens Hood for a given lens on APS-C cameras - PentaxForums.com