Fixed possible buffer overflows. Patch by Jérémy Bobbio.