From: Kern Sibbald Date: Fri, 30 May 2008 10:36:49 +0000 (+0000) Subject: Fix possible seg fault if SQL error. X-Git-Tag: Release-2.4.0~19 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b33146251a11aa8e24f1204de190178869842ec9;p=bacula%2Fbacula Fix possible seg fault if SQL error. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@7057 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sql.c b/bacula/src/cats/sql.c index 8a61c449d9..99503f7c8b 100644 --- a/bacula/src/cats/sql.c +++ b/bacula/src/cats/sql.c @@ -468,6 +468,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, "-"); } @@ -500,6 +503,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) { @@ -531,6 +537,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); } @@ -543,6 +552,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])) { @@ -565,6 +577,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 4f97d02790..5abb690381 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.2.10-b4" -#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.1 b/bacula/technotes-2.1 index 4ab0a6da64..0b3895a883 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,8 @@ Technical notes on version 2.2 General: +30May08 +kes Fix possible seg fault if SQL error. 28May08 kes Add debug code to SD. kes Fix renaming a Volume, which used the wrong Volume name.