buffer: properly cast offset