Fix null pointer check in tokenFilename()

From https://scan.coverity.com/projects/chromium-ec :
CID61407: Dereference after null check

The home directory that is received from getpwuid()
needs to be assigned to home but it wasn't.

BUG=none
BRANCH=none
TEST=build tested
Signed-off-by: Stefan Reinauer <reinauer@chromium.org>

Change-Id: I36c30906e1388e2f8a0d466d516a5ffa6ae70bf6
Reviewed-on: https://chromium-review.googlesource.com/324637
Commit-Ready: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
This commit is contained in:
Stefan Reinauer
2016-02-01 10:08:33 -08:00
committed by chrome-bot
parent c8484a9138
commit 4f6f505900

View File

@@ -294,7 +294,8 @@ void getPIN(uint8_t* out) {
static
std::string tokenFilename(const uint8_t* fp) {
const char* home = getenv("HOME");
if (home == NULL) getpwuid(getuid())->pw_dir;
if (home == NULL)
home = getpwuid(getuid())->pw_dir;
std::string s(home);
s.append("/.tmp/");
for (int i = 0; i < 32; ++i) {