From 841f8db24dd2cc4b0d0333427fdd78ee621a6ae4 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 23 Aug 2007 07:05:47 +0000 Subject: [PATCH] 23Aug07 kes Fix (hopefully) bug #930 by doing a db_escape_string() on file and directory names during restore of single file/directories. kes Add sanity checks to .sql command when string is empty. Hopefully that will resolve Dirks Director crash. 22Aug07 kes Apply patch submitted by Martin Simmons that corrects a seg fault in the bsmtp chat subroutine when debug is >= 10. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5398 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/ua_dotcmds.c | 6 +++++- bacula/src/dird/ua_output.c | 14 +++++++++----- bacula/src/dird/ua_restore.c | 10 ++++------ bacula/src/tools/bsmtp.c | 4 +++- bacula/src/version.h | 4 ++-- bacula/technotes-2.3 | 8 ++++++++ 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/bacula/src/dird/ua_dotcmds.c b/bacula/src/dird/ua_dotcmds.c index a87319f372..d8f4695074 100644 --- a/bacula/src/dird/ua_dotcmds.c +++ b/bacula/src/dird/ua_dotcmds.c @@ -474,7 +474,11 @@ static int sql_handler(void *ctx, int num_field, char **row) } pm_strcat(rows, "\t"); } - ua->send_msg("%s", rows.c_str()); + if (!rows.c_str() || !*rows.c_str()) { + ua->send_msg("\t"); + } else { + ua->send_msg("%s", rows.c_str()); + } return 0; } diff --git a/bacula/src/dird/ua_output.c b/bacula/src/dird/ua_output.c index 01c76f1a20..8bf7178d22 100644 --- a/bacula/src/dird/ua_output.c +++ b/bacula/src/dird/ua_output.c @@ -725,11 +725,12 @@ void bmsg(UAContext *ua, const char *fmt, va_list arg_ptr) { BSOCK *bs = ua->UA_sock; int maxlen, len; - POOLMEM *msg; + POOLMEM *msg = NULL; if (bs) { msg = bs->msg; - } else { + } + if (!msg) { msg = get_pool_memory(PM_EMSG); } @@ -785,8 +786,9 @@ void UAContext::error_msg(const char *fmt, ...) { BSOCK *bs = UA_sock; va_list arg_ptr; - va_start(arg_ptr, fmt); + if (bs && api) bs->signal(BNET_ERROR_MSG); + va_start(arg_ptr, fmt); bmsg(this, fmt, arg_ptr); va_end(arg_ptr); } @@ -800,8 +802,9 @@ void UAContext::warning_msg(const char *fmt, ...) { BSOCK *bs = UA_sock; va_list arg_ptr; - va_start(arg_ptr, fmt); + if (bs && api) bs->signal(BNET_WARNING_MSG); + va_start(arg_ptr, fmt); bmsg(this, fmt, arg_ptr); va_end(arg_ptr); } @@ -814,8 +817,9 @@ void UAContext::info_msg(const char *fmt, ...) { BSOCK *bs = UA_sock; va_list arg_ptr; - va_start(arg_ptr, fmt); + if (bs && api) bs->signal(BNET_INFO_MSG); + va_start(arg_ptr, fmt); bmsg(this, fmt, arg_ptr); va_end(arg_ptr); } diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index ffae520a02..cedea941e5 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -967,9 +967,8 @@ static void split_path_and_filename(RESTORE_CTX *rx, char *name) */ rx->fnl = p - f; if (rx->fnl > 0) { - rx->fname = check_pool_memory_size(rx->fname, rx->fnl+1); - memcpy(rx->fname, f, rx->fnl); /* copy filename */ - rx->fname[rx->fnl] = 0; + rx->fname = check_pool_memory_size(rx->fname, 2*(rx->fnl)+1); + db_escape_string(rx->fname, f, rx->fnl); } else { rx->fname[0] = 0; rx->fnl = 0; @@ -977,9 +976,8 @@ static void split_path_and_filename(RESTORE_CTX *rx, char *name) rx->pnl = f - name; if (rx->pnl > 0) { - rx->path = check_pool_memory_size(rx->path, rx->pnl+1); - memcpy(rx->path, name, rx->pnl); - rx->path[rx->pnl] = 0; + rx->path = check_pool_memory_size(rx->path, 2*(rx->pnl)+1); + db_escape_string(rx-path, name, rx->pnl); } else { rx->path[0] = 0; rx->pnl = 0; diff --git a/bacula/src/tools/bsmtp.c b/bacula/src/tools/bsmtp.c index 93eae1ba38..03b5f5c3a7 100644 --- a/bacula/src/tools/bsmtp.c +++ b/bacula/src/tools/bsmtp.c @@ -136,11 +136,13 @@ static void chat(const char *fmt, ...) va_start(ap, fmt); vfprintf(sfp, fmt, ap); + va_end(ap); if (debug_level >= 10) { fprintf(stdout, "%s --> ", my_hostname); + va_start(ap, fmt); vfprintf(stdout, fmt, ap); + va_end(ap); } - va_end(ap); fflush(sfp); if (debug_level >= 10) { diff --git a/bacula/src/version.h b/bacula/src/version.h index 02778fb5fd..6ddcfdbbc1 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.3.1" -#define BDATE "21 August 2007" -#define LSMDATE "21Aug07" +#define BDATE "23 August 2007" +#define LSMDATE "23Aug07" #define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n" #define BYEAR "2007" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 5f5235f9a0..30360e6578 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,6 +1,14 @@ Technical notes on version 2.3 General: +23Aug07 +kes Fix (hopefully) bug #930 by doing a db_escape_string() on file + and directory names during restore of single file/directories. +kes Add sanity checks to .sql command when string is empty. Hopefully + that will resolve Dirks Director crash. +22Aug07 +kes Apply patch submitted by Martin Simmons that corrects a seg fault + in the bsmtp chat subroutine when debug is >= 10. 21Aug07 kes Fix Director crash when running bat SQL queries. kes Add David's notes on Item 8: Copy pools. -- 2.39.5