summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2017-10-05 15:35:23 +0200
committerchrome-bot <chrome-bot@chromium.org>2017-10-09 03:06:27 -0700
commitf1e6af516c87623f475900f8fc85cb9c40668092 (patch)
tree88ad62816ee88c87725252de4af6bf17288139ae
parent4bd4161317ad1a3bad6b90541ddfbfdc48f6d31e (diff)
downloadchrome-ec-f1e6af516c87623f475900f8fc85cb9c40668092.tar.gz
util/ectool.c: Make sure device_name is NUL terminated
BRANCH=none BUG=none TEST=none Found-by: Coverity Scan #144116 Change-Id: I9ec030c1a3820af7d08c2a83e3c1f4c3ee7a3f0a Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/702302 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Chris Ching <chingcodes@chromium.org>
-rw-r--r--util/ectool.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/ectool.c b/util/ectool.c
index 0fecb6db83..ff41538b44 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -7337,7 +7337,7 @@ int main(int argc, char *argv[])
const struct command *cmd;
int dev = 0;
int interfaces = COMM_ALL;
- char device_name[40] = CROS_EC_DEV_NAME;
+ char device_name[41] = CROS_EC_DEV_NAME;
int rv = 1;
int parse_error = 0;
char *e;
@@ -7374,6 +7374,7 @@ int main(int argc, char *argv[])
break;
case OPT_NAME:
strncpy(device_name, optarg, 40);
+ device_name[40] = '\0';
break;
}
}