several bugs and security fixes fix an off-by-one in c-client, referenced by CVE-2008-5514 thanks to jasper@ for the heads-up