From: Garrett Wollman Date: Tue, 9 Aug 2011 01:18:15 +0000 (-0400) Subject: kdb: don't dereference a null pointer on corrupt database X-Git-Tag: upstream/1.6.0^2~54 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=24471095dc768f13c4b246f1ff04c5793c93a1c3;p=packages%2Fo%2Fopenafs.git kdb: don't dereference a null pointer on corrupt database When iterating through the database, kdb would dereference a null pointer if it encountered an error retrieving the value or if the value was not the right length, in code that was clearly cut-and-pasted from the other branch of an "if" statement where a specific entry was requested on the command line. Print the name of the entry with the problem as was apparently intended. Found-by: clang static analyzer Reviewed-on: http://gerrit.openafs.org/5174 Tested-by: BuildBot Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear (cherry picked from commit ae6a3929489035ddcd17785abab8900cebd22eb3) Change-Id: I5c79189f82a636b923c074d3c69cb3b6fef732aa Reviewed-on: http://gerrit.openafs.org/5188 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/kauth/kdb.c b/src/kauth/kdb.c index 5d73f6d22..2dd253ebf 100644 --- a/src/kauth/kdb.c +++ b/src/kauth/kdb.c @@ -51,11 +51,12 @@ cmdproc(struct cmd_syndesc *as, void * arock) if (as->parms[2].items) { data = dbm_fetch(kdb, key); if (!data.dptr) { - fprintf(stderr, "%s: no entry exists\n", ti->data); + fprintf(stderr, "%s: no entry exists\n", (char *)key.dptr); continue; } if (data.dsize != sizeof(kalog_elt)) { - fprintf(stderr, "%s: data came out corrupt\n", ti->data); + fprintf(stderr, "%s: data came out corrupt\n", + (char *)key.dptr); continue; } memcpy(&rdata, data.dptr, sizeof(kalog_elt));