From: Eric Bollengier Date: Tue, 16 Nov 2010 16:56:24 +0000 (+0100) Subject: bvfs: Tweak pattern in lsdir, lsfiles X-Git-Tag: Release-7.0.0~1400 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=074628c5711f0ce5e236bd96f589f3b993cee58d;p=bacula%2Fbacula bvfs: Tweak pattern in lsdir, lsfiles --- diff --git a/bacula/src/cats/bvfs.c b/bacula/src/cats/bvfs.c index 71f1964e35..3ef693cdcd 100644 --- a/bacula/src/cats/bvfs.c +++ b/bacula/src/cats/bvfs.c @@ -643,9 +643,13 @@ bool Bvfs::ls_dirs() return false; } + POOL_MEM query; POOL_MEM filter; if (*pattern) { - Mmsg(filter, " AND Path2.Path %s '%s' ", SQL_MATCH, pattern); + int len = strlen(pattern); + query.check_size(len*2+1); + db_escape_string(jcr, db, query.c_str(), pattern, len); + Mmsg(filter, " AND Path2.Path %s '%s' ", SQL_MATCH, query.c_str()); } if (!dir_filenameid) { @@ -661,7 +665,6 @@ bool Bvfs::ls_dirs() * my $dir_filenameid = $self->get_dir_filenameid(); */ /* Then we get all the dir entries from File ... */ - POOL_MEM query; Mmsg(query, // 0 1 2 3 4 5 6 "SELECT 'D', PathId, 0, Path, JobId, LStat, FileId FROM ( " @@ -739,7 +742,10 @@ bool Bvfs::ls_files() edit_uint64(pwd_id, pathid); if (*pattern) { - Mmsg(filter, " AND Filename.Name %s '%s' ", SQL_MATCH, pattern); + int len = strlen(pattern); + query.check_size(len*2+1); + db_escape_string(jcr, db, query.c_str(), pattern, len); + Mmsg(filter, " AND Filename.Name %s '%s' ", SQL_MATCH, query.c_str()); } build_ls_files_query(db, query,