From bc1130e954967ca82703b0cd4d09aad3858df7c7 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 26 Sep 2005 14:37:35 +0000 Subject: [PATCH] - Add code to catalog_update to detect NULL db pointer. - Remove char *msg argument from catalog_request and catalog_update(). git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2403 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kes-1.37 | 4 ++++ bacula/src/dird/catreq.c | 16 +++++++++++++--- bacula/src/dird/getmsg.c | 19 +++++++------------ bacula/src/dird/protos.h | 4 ++-- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index 854a4e65c1..cf4ea53e1f 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,6 +4,10 @@ General: Changes to 1.37.40: +26Sep05 +- Add code to catalog_update to detect NULL db pointer. +- Remove char *msg argument from catalog_request and + catalog_update(). 24Sep05 - Fix mode change open in btape.c - Use nonblocking opens on Linux only. diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index c563d35eac..6050941959 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -85,7 +85,7 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr return stat; } -void catalog_request(JCR *jcr, BSOCK *bs, char *msg) +void catalog_request(JCR *jcr, BSOCK *bs) { MEDIA_DBR mr, sdmr; JOBMEDIA_DBR jm; @@ -311,7 +311,7 @@ void catalog_request(JCR *jcr, BSOCK *bs, char *msg) * VolSessionId, VolSessionTime, FileIndex, and file name * to store in the catalog. */ -void catalog_update(JCR *jcr, BSOCK *bs, char *msg) +void catalog_update(JCR *jcr, BSOCK *bs) { unser_declare; uint32_t VolSessionId, VolSessionTime; @@ -322,10 +322,20 @@ void catalog_update(JCR *jcr, BSOCK *bs, char *msg) int len; char *fname, *attr; ATTR_DBR *ar = NULL; + POOLMEM *omsg; if (!jcr->pool->catalog_files) { return; /* user disabled cataloging */ } + if (!jcr->db) { + omsg = get_memory(bs->msglen+1); + pm_strcpy(omsg, bs->msg); + bnet_fsend(bs, _("1991 Invalid Catalog Update: %s"), omsg); + Jmsg1(jcr, M_FATAL, 0, _("Invalid Catalog Update; DB not open: %s"), omsg); + free_memory(omsg); + return; + } + /* Start transaction allocates jcr->attr and jcr->ar if needed */ db_start_transaction(jcr, jcr->db); /* start transaction if not already open */ ar = jcr->ar; @@ -387,7 +397,7 @@ void catalog_update(JCR *jcr, BSOCK *bs, char *msg) Dmsg2(400, "dirddb, ar)) { Jmsg1(jcr, M_FATAL, 0, _("Attribute create error. %s"), db_strerror(jcr->db)); } diff --git a/bacula/src/dird/getmsg.c b/bacula/src/dird/getmsg.c index b9d4247080..8150cb8972 100644 --- a/bacula/src/dird/getmsg.c +++ b/bacula/src/dird/getmsg.c @@ -24,19 +24,14 @@ Copyright (C) 2000-2005 Kern Sibbald This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. + modify it under the terms of the GNU General Public License + version 2 as amended with additional clauses defined in the + file LICENSE in the main source directory. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the Free - Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - MA 02111-1307, USA. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + the file LICENSE for additional details. */ @@ -198,14 +193,14 @@ int bget_dirmsg(BSOCK *bs) */ if (bs->msg[0] == 'C') { /* Catalog request */ Dmsg2(900, "Catalog req jcr 0x%x: %s", jcr, bs->msg); - catalog_request(jcr, bs, msg); + catalog_request(jcr, bs); Dmsg1(900, "Calling freejcr 0x%x\n", jcr); free_jcr(jcr); continue; } if (bs->msg[0] == 'U') { /* Catalog update */ Dmsg2(900, "Catalog upd jcr 0x%x: %s", jcr, bs->msg); - catalog_update(jcr, bs, msg); + catalog_update(jcr, bs); Dmsg1(900, "Calling freejcr 0x%x\n", jcr); free_jcr(jcr); continue; diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index 8917124961..5938e0e14b 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -56,8 +56,8 @@ void make_unique_restore_filename(UAContext *ua, POOLMEM **fname); /* catreq.c */ -extern void catalog_request(JCR *jcr, BSOCK *bs, char *buf); -extern void catalog_update(JCR *jcr, BSOCK *bs, char *buf); +extern void catalog_request(JCR *jcr, BSOCK *bs); +extern void catalog_update(JCR *jcr, BSOCK *bs); /* dird_conf.c */ extern const char *level_to_str(int level); -- 2.39.2