diff options
author | David Hendricks <dhendrix@chromium.org> | 2012-09-05 14:42:03 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-09-06 10:07:23 -0700 |
commit | c5652fbcfcf585bd2957a8a2a340303e04810a81 (patch) | |
tree | edbf2ffe739b211d5e9791b0e57a78e189060e4b | |
parent | 8a9471e5ef305a2aea81e6cb62a17d6966865b6b (diff) | |
download | chrome-ec-c5652fbcfcf585bd2957a8a2a340303e04810a81.tar.gz |
make build_info fixed-length
This makes build_info fixed-length so that it can be properly
transmitted via I2C. The host buffer size will be used, which may
in fact be quite a bit longer than necessary. Build info will be
truncated if it's longer than the max response size.
Signed-off-by: David Hendricks <dhendrix@chromium.org>
BRANCH=snow
BUG=chrome-os-partner:11608
TEST=Tested on Snow, logic analyzer confirmed NAK and STOP condition
set properly after final byte transmitted via I2C (see BUG)
Change-Id: Iccae0f3c2905d442c8eebff42aa19bf940e5f71f
Reviewed-on: https://gerrit.chromium.org/gerrit/32290
Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
Commit-Ready: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
-rw-r--r-- | common/system_common.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/common/system_common.c b/common/system_common.c index e88a377b63..847e808fd2 100644 --- a/common/system_common.c +++ b/common/system_common.c @@ -776,9 +776,12 @@ DECLARE_HOST_COMMAND(EC_CMD_GET_VERSION, static int host_command_build_info(struct host_cmd_handler_args *args) { const char *info = system_get_build_info(); + int len; - args->response = (uint8_t *)info; - args->response_size = strlen(info) + 1; + len = MIN(strlen(info), args->response_max - 1); + args->response_size = args->response_max; + memcpy(args->response, info, len); + memset(args->response + len, 0, args->response_size - len); return EC_RES_SUCCESS; } |