summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-01-21 18:09:49 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-22 05:13:36 +0000
commite33c30c14949d4712a663cddaddc61a57776f849 (patch)
treefe2d0c28f94e2399f19d844a4cdebc0de831b072 /common
parenta84e31579204ad531f30455d8d2879b0d4685e6a (diff)
downloadchrome-ec-e33c30c14949d4712a663cddaddc61a57776f849.tar.gz
pd: make sure all host commands range check type-C port arg
Add range checking of type-C port arg to host commands that weren't already doing so. BUG=chrome-os-partner:31492 BRANCH=samus TEST=make -j buildall > ectool --dev=1 usbpd 2 EC result 3 (INVALID_PARAM) Change-Id: I0bd7677857f28fc002a039c477e87efa876d0134 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/242423 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/usb_pd_protocol.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index c18af2093a..234f024624 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -3262,6 +3262,9 @@ static int hc_usb_pd_control(struct host_cmd_handler_args *args)
struct ec_response_usb_pd_control_v1 *r_v1 = args->response;
struct ec_response_usb_pd_control *r = args->response;
+ if (p->port >= PD_PORT_COUNT)
+ return EC_RES_INVALID_PARAM;
+
if (p->role >= USB_PD_CTRL_ROLE_COUNT ||
p->mux >= USB_PD_CTRL_MUX_COUNT)
return EC_RES_INVALID_PARAM;
@@ -3305,6 +3308,9 @@ static int hc_remote_flash(struct host_cmd_handler_args *args)
int i, size, rv = EC_RES_SUCCESS;
timestamp_t timeout;
+ if (port >= PD_PORT_COUNT)
+ return EC_RES_INVALID_PARAM;
+
if (p->size + sizeof(*p) > args->params_size)
return EC_RES_INVALID_PARAM;