From ae6a3929489035ddcd17785abab8900cebd22eb3 Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Mon, 8 Aug 2011 21:18:15 -0400 Subject: [PATCH] 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. Change-Id: Idc2d3c9b6049e5d3b0eb302353a68bcfdad6a90d Found-by: clang static analyzer Reviewed-on: http://gerrit.openafs.org/5174 Tested-by: BuildBot Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear --- src/kauth/kdb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/kauth/kdb.c b/src/kauth/kdb.c index 081a52a2e..0703cdd39 100644 --- a/src/kauth/kdb.c +++ b/src/kauth/kdb.c @@ -46,11 +46,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)); -- 2.39.5