|
Tomas Hozza |
4242e4 |
From 75f51e2f14d9fce2001aa91ad444e327321a19c3 Mon Sep 17 00:00:00 2001
|
|
Tomas Hozza |
4242e4 |
From: Tomas Hozza <thozza@redhat.com>
|
|
Tomas Hozza |
4242e4 |
Date: Thu, 2 May 2013 15:05:51 +0200
|
|
Tomas Hozza |
4242e4 |
Subject: [PATCH] Table name should be quoted when used in SQL commands
|
|
Tomas Hozza |
4242e4 |
|
|
Tomas Hozza |
4242e4 |
Table name should be quoted when dropping/creating/inserting in
|
|
Tomas Hozza |
4242e4 |
some table. Currently zone2sqlite is unable to handle table
|
|
Tomas Hozza |
4242e4 |
names starting with ".", "-", number, etc.
|
|
Tomas Hozza |
4242e4 |
|
|
Tomas Hozza |
4242e4 |
This can be solved by using "%Q" instead of "%q" in sqlite3_mprintf()
|
|
Tomas Hozza |
4242e4 |
calls when inserting table name.
|
|
Tomas Hozza |
4242e4 |
|
|
Tomas Hozza |
4242e4 |
Signed-off-by: Tomas Hozza <thozza@redhat.com>
|
|
Tomas Hozza |
4242e4 |
---
|
|
Tomas Hozza |
4242e4 |
contrib/sdb/sqlite/zone2sqlite.c | 6 +++---
|
|
Tomas Hozza |
4242e4 |
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
Tomas Hozza |
4242e4 |
|
|
Tomas Hozza |
4242e4 |
diff --git a/contrib/sdb/sqlite/zone2sqlite.c b/contrib/sdb/sqlite/zone2sqlite.c
|
|
Tomas Hozza |
4242e4 |
index b583d2b..7b9260a 100644
|
|
Tomas Hozza |
4242e4 |
--- a/contrib/sdb/sqlite/zone2sqlite.c
|
|
Tomas Hozza |
4242e4 |
+++ b/contrib/sdb/sqlite/zone2sqlite.c
|
|
Tomas Hozza |
4242e4 |
@@ -129,7 +129,7 @@ addrdata(dns_name_t *name, dns_ttl_t ttl, dns_rdata_t *rdata)
|
|
Tomas Hozza |
4242e4 |
dataarray[isc_buffer_usedlength(&b)] = 0;
|
|
Tomas Hozza |
4242e4 |
|
|
Tomas Hozza |
4242e4 |
sql = sqlite3_mprintf(
|
|
Tomas Hozza |
4242e4 |
- "INSERT INTO %q (NAME, TTL, RDTYPE, RDATA)"
|
|
Tomas Hozza |
4242e4 |
+ "INSERT INTO %Q (NAME, TTL, RDTYPE, RDATA)"
|
|
Tomas Hozza |
4242e4 |
" VALUES ('%q', %d, '%q', '%q') ",
|
|
Tomas Hozza |
4242e4 |
dbi.table,
|
|
Tomas Hozza |
4242e4 |
namearray, ttl, typearray, dataarray);
|
|
Tomas Hozza |
4242e4 |
@@ -208,7 +208,7 @@ main(int argc, char *argv[])
|
|
Tomas Hozza |
4242e4 |
closeandexit(1);
|
|
Tomas Hozza |
4242e4 |
}
|
|
Tomas Hozza |
4242e4 |
|
|
Tomas Hozza |
4242e4 |
- sql = sqlite3_mprintf("DROP TABLE %q ", dbi.table);
|
|
Tomas Hozza |
4242e4 |
+ sql = sqlite3_mprintf("DROP TABLE %Q ", dbi.table);
|
|
Tomas Hozza |
4242e4 |
printf("%s\n", sql);
|
|
Tomas Hozza |
4242e4 |
res = sqlite3_exec(dbi.db, sql, NULL, NULL, &errmsg);
|
|
Tomas Hozza |
4242e4 |
sqlite3_free(sql);
|
|
Tomas Hozza |
4242e4 |
@@ -231,7 +231,7 @@ main(int argc, char *argv[])
|
|
Tomas Hozza |
4242e4 |
#endif
|
|
Tomas Hozza |
4242e4 |
|
|
Tomas Hozza |
4242e4 |
sql = sqlite3_mprintf(
|
|
Tomas Hozza |
4242e4 |
- "CREATE TABLE %q "
|
|
Tomas Hozza |
4242e4 |
+ "CREATE TABLE %Q "
|
|
Tomas Hozza |
4242e4 |
"(NAME TEXT, TTL INTEGER, RDTYPE TEXT, RDATA TEXT) ",
|
|
Tomas Hozza |
4242e4 |
dbi.table);
|
|
Tomas Hozza |
4242e4 |
printf("%s\n", sql);
|
|
Tomas Hozza |
4242e4 |
--
|
|
Tomas Hozza |
4242e4 |
1.8.1.4
|
|
Tomas Hozza |
4242e4 |
|