From: Marcin Haba Date: Mon, 20 Aug 2018 17:48:53 +0000 (+0200) Subject: Fix escaping special characters in bvfs restore for sqlite catalog X-Git-Tag: Release-9.2.2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a525fb7e682e1679b0e3a9e968018fcc5c3fe592;p=thirdparty%2Fbacula.git Fix escaping special characters in bvfs restore for sqlite catalog --- diff --git a/bacula/src/cats/bvfs.c b/bacula/src/cats/bvfs.c index 787b1a72b..e5c21835f 100644 --- a/bacula/src/cats/bvfs.c +++ b/bacula/src/cats/bvfs.c @@ -1413,8 +1413,8 @@ bool Bvfs::compute_restore_list(char *fileid, char *dirid, char *hardlink, Mmsg(tmp, "SELECT Job.JobId, JobTDate, File.FileIndex, File.FilenameId, " "File.PathId, FileId " "FROM Path JOIN File USING (PathId) JOIN Job USING (JobId) " - "WHERE Path.Path LIKE '%s' AND File.JobId IN (%s) ", - tmp2.c_str(), jobids); + "WHERE Path.Path LIKE '%s' ESCAPE '%s' AND File.JobId IN (%s) ", + tmp2.c_str(), escape_char_value[db->bdb_get_type_index()], jobids); query.strcat(tmp.c_str()); init = true; diff --git a/bacula/src/cats/sql_cmds.c b/bacula/src/cats/sql_cmds.c index 5fe303153..4515a6d2f 100644 --- a/bacula/src/cats/sql_cmds.c +++ b/bacula/src/cats/sql_cmds.c @@ -1040,3 +1040,14 @@ const char *strip_restore[] = { /* SQLite */ "DELETE FROM %s WHERE FileId IN (SELECT FileId FROM %s JOIN File USING (FileId) WHERE PathId IN (%s))" }; + +static const char *escape_char_value_default = "\\"; + +const char *escape_char_value[] = { + /* MySQL */ + "\\\\", + /* PostgreSQL */ + escape_char_value_default, + /* SQLite */ + escape_char_value_default +}; \ No newline at end of file diff --git a/bacula/src/cats/sql_cmds.h b/bacula/src/cats/sql_cmds.h index 85211cbcd..2b02139a8 100644 --- a/bacula/src/cats/sql_cmds.h +++ b/bacula/src/cats/sql_cmds.h @@ -89,3 +89,4 @@ extern const char CATS_IMP_EXP *update_counter_values[]; extern const char CATS_IMP_EXP *expires_in[]; extern const char CATS_IMP_EXP *prune_cache[]; extern const char CATS_IMP_EXP *strip_restore[]; +extern const char CATS_IMP_EXP *escape_char_value[];