From: Kern Sibbald Date: Sun, 25 May 2008 13:13:20 +0000 (+0000) Subject: Fix a few more Coverity reported problems. X-Git-Tag: Release-7.0.0~4541 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=48b53b9fd540c50b055efab7792989ffc3cb625a;p=bacula%2Fbacula Fix a few more Coverity reported problems. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7029 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/AUTHORS b/bacula/AUTHORS index 72282f4e96..a1ae6dabf4 100644 --- a/bacula/AUTHORS +++ b/bacula/AUTHORS @@ -81,6 +81,7 @@ Peter Much Philippe Chauvat Phil Stracchino Preben Guldberg +Riccardo Ghetta Richard Mortimer Robert Nelson Rudolf Cejka diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index 2b624f8235..17e8a74511 100644 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -384,17 +384,16 @@ static BPIPE *open_mail_pipe(JCR *jcr, POOLMEM *&cmd, DEST *d) } fflush(stdout); - if (!(bpipe = open_bpipe(cmd, 120, "rw"))) { + if ((bpipe = open_bpipe(cmd, 120, "rw"))) { + /* If we had to use sendmail, add subject */ + if (!d->mail_cmd) { + fprintf(bpipe->wfd, "Subject: %s\r\n\r\n", _("Bacula Message")); + } + } else { berrno be; Jmsg(jcr, M_ERROR, 0, _("open mail pipe %s failed: ERR=%s\n"), cmd, be.bstrerror()); } - - /* If we had to use sendmail, add subject */ - if (!d->mail_cmd) { - fprintf(bpipe->wfd, "Subject: %s\r\n\r\n", _("Bacula Message")); - } - return bpipe; } diff --git a/bacula/src/lib/smartall.c b/bacula/src/lib/smartall.c index 9ebfbbb13c..862cce5471 100644 --- a/bacula/src/lib/smartall.c +++ b/bacula/src/lib/smartall.c @@ -451,18 +451,21 @@ int sm_check_rtn(const char *fname, int lineno, bool bufdump) P(mutex); ap = (struct abufhead *) abqueue.qnext; - while (ap != (struct abufhead *) &abqueue) { + while (ap != (struct abufhead *)&abqueue) { bad = 0; - if ((ap == NULL) || - (ap->abq.qnext->qprev != (struct b_queue *) ap)) { - bad = 0x1; - } - if (ap->abq.qprev->qnext != (struct b_queue *) ap) { - bad |= 0x2; - } - if (((unsigned char *) ap)[((struct abufhead *) ap)->ablen - 1] != - ((((long) ap) & 0xFF) ^ 0xC5)) { - bad |= 0x4; + if (ap != NULL) { + if (ap->abq.qnext->qprev != (struct b_queue *)ap) { + bad = 0x1; + } + if (ap->abq.qprev->qnext != (struct b_queue *)ap) { + bad |= 0x2; + } + if (((unsigned char *) ap)[((struct abufhead *)ap)->ablen - 1] != + ((((long) ap) & 0xFF) ^ 0xC5)) { + bad |= 0x4; + } + } else { + bad = 0x8; } badbuf |= bad; if (bad) { @@ -478,7 +481,13 @@ int sm_check_rtn(const char *fname, int lineno, bool bufdump) if (bad & 0x4) { fprintf(stderr, _(" discovery of data overrun.\n")); } + if (bad & 0x8) { + fprintf(stderr, _(" NULL pointer.\n")); + } + if (!ap) { + goto get_out; + } fprintf(stderr, _(" Buffer address: %p\n"), ap); if (ap->abfname != NULL) { @@ -515,8 +524,9 @@ int sm_check_rtn(const char *fname, int lineno, bool bufdump) } } } - ap = (struct abufhead *) ap->abq.qnext; + ap = (struct abufhead *)ap->abq.qnext; } +get_out: V(mutex); return badbuf ? 0 : 1; } diff --git a/bacula/src/stored/match_bsr.c b/bacula/src/stored/match_bsr.c index e8dbdc2fdd..2552eee607 100644 --- a/bacula/src/stored/match_bsr.c +++ b/bacula/src/stored/match_bsr.c @@ -193,7 +193,11 @@ BSR *find_next_bsr(BSR *root_bsr, DEVICE *dev) BSR *found_bsr = NULL; /* Do tape/disk seeking only if CAP_POSITIONBLOCKS is on */ - if (!root_bsr || !root_bsr->use_positioning || + if (!root_bsr) { + Dmsg0(dbglevel, "NULL root bsr pointer passed to find_next_bsr.\n"); + return NULL; + } + if (!root_bsr->use_positioning || !root_bsr->reposition || !dev->has_cap(CAP_POSITIONBLOCKS)) { Dmsg2(dbglevel, "No nxt_bsr use_pos=%d repos=%d\n", root_bsr->use_positioning, root_bsr->reposition); return NULL; diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 553f880484..6c8b6b5abe 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -24,6 +24,8 @@ Add long term statistics job table General: +25May08 +kes Fix a few more Coverity reported problems. 24May08 kes Apply Allan Black's status dir job count patch. ebl Add information about IMPORT/EXPORT slots in mtx-script.