[PATCH 4.9 089/310] ray_cs: Avoid reading past end of buffer