session: Avoid issues with \0 bytes