]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix escaping special characters in bvfs restore for sqlite catalog
authorMarcin Haba <marcin.haba@bacula.pl>
Mon, 20 Aug 2018 17:48:53 +0000 (19:48 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Mon, 20 Aug 2018 17:48:53 +0000 (19:48 +0200)
bacula/src/cats/bvfs.c
bacula/src/cats/sql_cmds.c
bacula/src/cats/sql_cmds.h

index 787b1a72b1409bff7cd10255f8836410c4656e6b..e5c21835f0f59952dda435af6ceb969ac5d9e882 100644 (file)
@@ -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;
 
index 5fe303153b594260669240be1ad65ba51117e0df..4515a6d2f774e2598a398cc64976dd2c95f9cb2f 100644 (file)
@@ -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
index 85211cbcd9c7247251c5d10403875104f51b7793..2b02139a81c8a3e2920fc0ad9378853c65ad98fe 100644 (file)
@@ -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[];