diff options
author | Vic Yang <victoryang@chromium.org> | 2013-05-26 16:07:14 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-05-28 12:53:55 -0700 |
commit | a46d5e7f3700e126c6bc5c31f93a8f297e11074f (patch) | |
tree | 886e2f062e52e4e3c798556b530ba93efa95163d | |
parent | 83ea309f44806bf49ea2780a1882473f79e4b1e8 (diff) | |
download | chrome-ec-a46d5e7f3700e126c6bc5c31f93a8f297e11074f.tar.gz |
Fix a bug in emulator persistent storage
The path string is not terminated properly, causing occasional crashes.
BUG=chrome-os-partner:19235
TEST=Dump the path and check it's correct.
BRANCH=None
Change-Id: I9ccbd565ce68ffdad98f2dd90ecf19edf9805ec0
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/56700
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | chip/host/persistence.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/chip/host/persistence.c b/chip/host/persistence.c index bf3ce01788..cd412fa7eb 100644 --- a/chip/host/persistence.c +++ b/chip/host/persistence.c @@ -14,8 +14,10 @@ static void get_storage_path(char *out) { char buf[BUF_SIZE]; + int sz; - readlink("/proc/self/exe", buf, BUF_SIZE); + sz = readlink("/proc/self/exe", buf, BUF_SIZE); + buf[sz] = '\0'; if (snprintf(out, BUF_SIZE, "%s_persist", buf) >= BUF_SIZE) out[BUF_SIZE - 1] = '\0'; } |