Fixes CVE-2017-12172, CVE-2017-15098 and CVE-2017-15099. Signed-off-by: Daniel Golle <daniel@makrotopia.org>