From 3fce682f882de346474bf97cc9255799b334197b Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 30 May 2008 10:36:13 +0000 Subject: [PATCH] Fix possible seg fault if SQL error. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7056 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/cats/sql.c | 15 +++++++++++++++ bacula/src/version.h | 4 ++-- bacula/technotes-2.3 | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index 56b9ccaf04..263b071434 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -508,6 +508,9 @@ list_dashes(B_DB *mdb, DB_LIST_HANDLER *send, void *ctx) send(ctx, "+"); for (i = 0; i < sql_num_fields(mdb); i++) { field = sql_fetch_field(mdb); + if (!field) { + break; + } for (j = 0; j < (int)field->max_length + 2; j++) { send(ctx, "-"); } @@ -540,6 +543,9 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t for (i = 0; i < sql_num_fields(mdb); i++) { Dmsg1(800, "list_result processing field %d\n", i); field = sql_fetch_field(mdb); + if (!field) { + break; + } col_len = cstrlen(field->name); if (type == VERT_LIST) { if (col_len > max_len) { @@ -571,6 +577,9 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t for (i = 0; i < sql_num_fields(mdb); i++) { Dmsg1(800, "list_result looking at field %d\n", i); field = sql_fetch_field(mdb); + if (!field) { + break; + } bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, field->name); send(ctx, buf); } @@ -583,6 +592,9 @@ list_result(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *send, void *ctx, e_list_type t send(ctx, "|"); for (i = 0; i < sql_num_fields(mdb); i++) { field = sql_fetch_field(mdb); + if (!field) { + break; + } if (row[i] == NULL) { bsnprintf(buf, sizeof(buf), " %-*s |", (int)field->max_length, "NULL"); } else if (IS_NUM(field->type) && !jcr->gui && is_an_integer(row[i])) { @@ -605,6 +617,9 @@ vertical_list: sql_field_seek(mdb, 0); for (i = 0; i < sql_num_fields(mdb); i++) { field = sql_fetch_field(mdb); + if (!field) { + break; + } if (row[i] == NULL) { bsnprintf(buf, sizeof(buf), " %*s: %s\n", max_len, field->name, "NULL"); } else if (IS_NUM(field->type) && !jcr->gui && is_an_integer(row[i])) { diff --git a/bacula/src/version.h b/bacula/src/version.h index bfe8b98b47..631418bed5 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.3.22" -#define BDATE "28 May 2008" -#define LSMDATE "28May08" +#define BDATE "30 May 2008" +#define LSMDATE "30May08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 27ff147c34..bdebafd548 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -24,6 +24,8 @@ Add long term statistics job table General: +30May08 +kes Fix possible seg fault if SQL error. 28May08 kes Add Martin's fixes to argument scanning for the estimate command. This fixes bug #1093. -- 2.39.5