From: Andreas Steffen Date: Sun, 30 Oct 2011 18:13:56 +0000 (+0100) Subject: fixed SQL queries X-Git-Tag: 4.6.2~278 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e4ac6698bd0bc5899f36ce5814f17b2b88d0710b;p=thirdparty%2Fstrongswan.git fixed SQL queries --- diff --git a/src/libimcv/plugins/imv_attestation/attest.c b/src/libimcv/plugins/imv_attestation/attest.c index 5210cd632f..8fbfb200bc 100644 --- a/src/libimcv/plugins/imv_attestation/attest.c +++ b/src/libimcv/plugins/imv_attestation/attest.c @@ -190,8 +190,10 @@ static void list_hashes(pts_meas_algorithms_t algo) e = db->query(db, "SELECT f.id, f.path, p.name, fh.hash, fh.directory " - "FROM files AS f, products AS p, file_hashes AS fh " - "WHERE fh.algo = ? AND f.id = fh.file AND p.id = fh.product " + "FROM file_hashes AS fh " + "JOIN files AS f ON f.id = fh.file " + "JOIN products AS p ON p.id = fh.product " + "WHERE fh.algo = ? " "ORDER BY fh.directory, f.path, p.name", DB_INT, algo, DB_INT, DB_TEXT, DB_TEXT, DB_BLOB, DB_INT); if (e) @@ -203,11 +205,11 @@ static void list_hashes(pts_meas_algorithms_t algo) if (did != did_old) { get_directory(did, &dir); + did_old = did; } printf("%3d: %s%s%s\n", fid, dir, slash(dir, file) ? "/" : "", file); fid_old = fid; - did_old = did; } printf(" %#B '%s'\n", &hash, product); count++; @@ -236,9 +238,10 @@ static void list_hashes_for_file(pts_meas_algorithms_t algo, char *file, int fid { e = db->query(db, "SELECT p.name, fh.hash, fh.directory " - "FROM products AS p, file_hashes AS fh " + "FROM file_hashes AS fh " "JOIN files AS f ON f.id = fh.file " - "WHERE fh.algo = ? AND f.id = ? AND p.id = fh.product " + "JOIN products AS p ON p.id = fh.product " + "WHERE fh.algo = ? AND f.id = ? " "ORDER BY p.name", DB_INT, algo, DB_INT, fid, DB_TEXT, DB_BLOB, DB_INT); } @@ -246,9 +249,10 @@ static void list_hashes_for_file(pts_meas_algorithms_t algo, char *file, int fid { e = db->query(db, "SELECT p.name, fh.hash, fh.directory " - "FROM products AS p, file_hashes AS fh " + "FROM file_hashes AS fh " "JOIN files AS f ON f.id = fh.file " - "WHERE fh.algo = ? AND f.path = ? AND p.id = fh.product " + "JOIN products AS p ON p.id = fh.product " + "WHERE fh.algo = ? AND f.path = ? " "ORDER BY p.name", DB_INT, algo, DB_TEXT, file, DB_TEXT, DB_BLOB, DB_INT); } @@ -287,9 +291,10 @@ static void list_hashes_for_product(pts_meas_algorithms_t algo, { e = db->query(db, "SELECT f.id, f. f.path, fh.hash, fh.directory " - "FROM files AS f, file_hashes AS fh " + "FROM file_hashes AS fh " + "JOIN files AS f ON f.id = fh.file " "JOIN products AS p ON p.id = fh.product " - "WHERE fh.algo = ? AND p.id = ? AND f.id = fh.file " + "WHERE fh.algo = ? AND p.id = ? " "ORDER BY fh.directory, f.path", DB_INT, algo, DB_INT, pid, DB_INT, DB_TEXT, DB_BLOB, DB_INT); } @@ -297,9 +302,10 @@ static void list_hashes_for_product(pts_meas_algorithms_t algo, { e = db->query(db, "SELECT f.id, f.path, fh.hash, fh.directory " - "FROM files AS f, file_hashes AS fh " + "FROM file_hashes AS fh " + "JOIN files AS f ON f.id = fh.file " "JOIN products AS p ON p.id = fh.product " - "WHERE fh.algo = ? AND p.name = ? AND f.id = fh.file " + "WHERE fh.algo = ? AND p.name = ? " "ORDER BY fh.directory, f.path", DB_INT, algo, DB_TEXT, product, DB_INT, DB_TEXT, DB_BLOB, DB_INT); }