From bc30fb4ce8dc6097bcc9d02b809aa94feef79bfa Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Mon, 1 May 2017 12:05:19 +0300 Subject: [PATCH] 8136 libnisdb: NULL pointer is used in wrong context Reviewed by: Yuri Pankov Reviewed by: Marcel Telka Reviewed by: Igor Kozhukhov Approved by: Robert Mustacchi --- usr/src/lib/libnisdb/db.cc | 4 +--- usr/src/lib/libnisdb/db_dictionary.cc | 2 +- usr/src/lib/libnisdb/db_log_c.x | 4 +--- usr/src/lib/libnisdb/db_table.cc | 18 +++++++++--------- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/usr/src/lib/libnisdb/db.cc b/usr/src/lib/libnisdb/db.cc index 61e45792fe..ef3def0f2e 100644 --- a/usr/src/lib/libnisdb/db.cc +++ b/usr/src/lib/libnisdb/db.cc @@ -26,8 +26,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #ifdef TDRPC @@ -487,7 +485,7 @@ db::open_log(bool_t copylog) logfile->copylog = copylog; - if ((logfile->open()) == NULL){ + if ((logfile->open()) == FALSE){ WARNING_M("db::open_log: could not open log file: "); delete logfile; logfile = NULL; diff --git a/usr/src/lib/libnisdb/db_dictionary.cc b/usr/src/lib/libnisdb/db_dictionary.cc index a642bb3f09..2b44a6a126 100644 --- a/usr/src/lib/libnisdb/db_dictionary.cc +++ b/usr/src/lib/libnisdb/db_dictionary.cc @@ -1402,7 +1402,7 @@ db_dictionary::open_log() return (0); } - if ((logfile->open()) == NULL) { + if ((logfile->open()) == FALSE) { WARNING_M("db_dictionary::open_log: could not open log file: "); delete logfile; logfile = NULL; diff --git a/usr/src/lib/libnisdb/db_log_c.x b/usr/src/lib/libnisdb/db_log_c.x index 96944ea165..1d9708eecf 100644 --- a/usr/src/lib/libnisdb/db_log_c.x +++ b/usr/src/lib/libnisdb/db_log_c.x @@ -26,8 +26,6 @@ * Use is subject to license terms. */ -%#pragma ident "%Z%%M% %I% %E% SMI" - #if RPC_HDR %#ifndef _DB_LOG_H %#define _DB_LOG_H @@ -100,7 +98,7 @@ %/* bool_t dump( pptr ) {return TRUE;}*/ // does nothing. % %/* Open log file */ -% int open(void); +% bool_t open(void); %/* Close log file */ % int close(); %/* Do we need to copy the log file */ diff --git a/usr/src/lib/libnisdb/db_table.cc b/usr/src/lib/libnisdb/db_table.cc index e68ea87d9a..c7cbfafcaf 100644 --- a/usr/src/lib/libnisdb/db_table.cc +++ b/usr/src/lib/libnisdb/db_table.cc @@ -145,14 +145,14 @@ db_free_list::reset() WRITEUNLOCKV(this, "wu db_free_list::reset"); } -/* Returns the location of a free entry, or NULL, if there aren't any. */ +/* Returns the location of a free entry, or 0, if there aren't any. */ entryp db_free_list::pop() { - WRITELOCK(this, NULL, "w db_free_list::pop"); + WRITELOCK(this, 0, "w db_free_list::pop"); if (head == NULL) { - WRITEUNLOCK(this, NULL, "wu db_free_list::pop"); - return (NULL); + WRITEUNLOCK(this, 0, "wu db_free_list::pop"); + return (0); } db_free_entry* old_head = head; entryp found = head->where; @@ -507,7 +507,7 @@ db_table::first_entry(entryp * where) { ASSERTRHELD(table); if (count == 0 || tab == NULL) { /* empty table */ - *where = NULL; + *where = 0; return (NULL); } else { entryp i; @@ -519,7 +519,7 @@ db_table::first_entry(entryp * where) } } } - *where = NULL; + *where = 0; return (NULL); } @@ -541,7 +541,7 @@ db_table::next_entry(entryp prev, entryp* newentry) return (tab[i]); } } - *newentry = NULL; + *newentry = 0; return (NULL); } @@ -662,7 +662,7 @@ db_table::add_entry(entry_object *obj, int initialLoad) { */ ASSERTWHELD(table); entryp where = freelist.pop(); - if (where == NULL) { /* empty freelist */ + if (where == 0) { /* empty freelist */ if (last_used >= (table_size-1)) /* full (> is for 0) */ grow(); where = ++last_used; @@ -676,7 +676,7 @@ db_table::add_entry(entry_object *obj, int initialLoad) { tab[where] = new_entry(obj); return (where); } else { - return (NULL); + return (0); } } -- 2.11.4.GIT