Fix some vulnerabilities

The vulnerabilities could lead to a crash of the applications due to array
bounds checks. This can happen if an attacker sends prepared packtest that
contain wrong data and/or have wrong length.