From 2442aed1dbdce908f331bb24d9888bdcbaa74473 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 25 Apr 2019 16:31:35 +0200 Subject: [PATCH] null pointer handling for strlcpy --- src/gamedb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gamedb.c b/src/gamedb.c index 9af580a9f..abd738ffc 100644 --- a/src/gamedb.c +++ b/src/gamedb.c @@ -17,10 +17,12 @@ static int generate_factions(void *data, db_faction *results, int nresults) faction **iter = (faction **)data; for (i = 0; *iter && i != nresults; ++i) { faction *f = *iter; + const char *pwhash; results[i].p_uid = &f->uid; results[i].no = f->no; results[i].email = faction_getemail(f); - str_strlcpy(results[i].pwhash, faction_getpassword(f), sizeof(results[i].pwhash)); + pwhash = faction_getpassword(f); + str_strlcpy(results[i].pwhash, pwhash ? pwhash : "", sizeof(results[i].pwhash)); *iter = f->next; } return i;