Fix off-by-one error in parsing ExtraSysTablePrefixes and table types.

I fixed these already once, but it was still off-by-one. Since we've been
burned by this twice now, refactor the code to make it more readable. Also
add a regression test case for the table types. The prefixes code is more
difficult to test since it's only used when connected to a pre-7.3 server.

Per report from Pavel Raiskup with help from Coverity static code analyzer.
Fix out-of-bounds write when Bind request packet size is a multiple of 4096.

Also add a test case to reproduce that bug on unpatched version.

Report and analysis by Patrice Dardoize.