From c5652fbcfcf585bd2957a8a2a340303e04810a81 Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Wed, 5 Sep 2012 14:42:03 -0700 Subject: 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 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 Commit-Ready: David Hendricks Tested-by: David Hendricks --- common/system_common.c | 7 +++++-- 1 file 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; } -- cgit v1.2.1