Fix buffer overflow and format string vulnerabilities. From an advisory by Ulf.Harnhammar.9485@student.uu.se.