[PATCH 3.18 037/121] ray_cs: Avoid reading past end of buffer