scst pr: Check buffer size before reading from that buffer

From: Bart Van Assche <bvanassche@acm.org>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4368 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2012-06-20 02:08:09 +00:00
parent b3855a377f
commit ca2aa8d3e7

View File

@@ -2026,11 +2026,6 @@ static void scst_pr_do_preempt(struct scst_cmd *cmd, uint8_t *buffer,
TRACE_ENTRY();
key = get_unaligned((__be64 *)&buffer[0]);
action_key = get_unaligned((__be64 *)&buffer[8]);
scope = (cmd->cdb[2] & 0x0f) >> 4;
type = cmd->cdb[2] & 0x0f;
if (buffer_size != 24) {
TRACE_PR("Invalid buffer size %d", buffer_size);
scst_set_cmd_error(cmd,
@@ -2038,6 +2033,11 @@ static void scst_pr_do_preempt(struct scst_cmd *cmd, uint8_t *buffer,
goto out;
}
key = get_unaligned((__be64 *)&buffer[0]);
action_key = get_unaligned((__be64 *)&buffer[8]);
scope = (cmd->cdb[2] & 0x0f) >> 4;
type = cmd->cdb[2] & 0x0f;
if (!scst_pr_type_valid(type)) {
TRACE_PR("Invalid reservation type %d", type);
scst_set_cmd_error(cmd,