This fixes CVE-2017-2807, CVE-2017-2808, CVE-2017-12481, CVE-2017-12482. OK jca@, Sergey Bronnikov (MAINTAINER)