Skip to content
Snippets Groups Projects
Commit 3fde641e authored by Corey Minyard's avatar Corey Minyard
Browse files

ipmi:smbus: Add a check around a memcpy


In one case:

  memcpy(sid->inmsg + sid->inlen, buf, len);

if len == 0 then sid->inmsg + sig->inlen can point to one past the inmsg
array if the array is full.  We have to allow len == 0 due to some
vagueness in the spec, but we don't have to call memcpy.

Found by Coverity.  This is not a problem in practice, but the results
are technically (maybe) undefined.  So make Coverity happy.

Reported-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parent cc42559a
No related branches found
No related tags found
No related merge requests found
......@@ -281,7 +281,9 @@ static int ipmi_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len)
*/
send = true;
}
memcpy(sid->inmsg + sid->inlen, buf, len);
if (len > 0) {
memcpy(sid->inmsg + sid->inlen, buf, len);
}
sid->inlen += len;
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment