11
SQL注入:是sqlite3_bind_text足以防止由於語句iPhone
const char *sql = "INSERT INTO FooTable (barStr) VALUES (?)";
是以下使用的sqlite3_bind_text
(及相關sqlite3_bind_*
功能)足以防止SQL注入攻擊?
sqlite3 *db;
sqlite3_stmt *dbps;
int dbrc = sqlite3_open([dbFilePath UTF8String], &db);
if (dbrc) {
// handle error
return;
}
dbrc = sqlite3_prepare_v2 (db, sql, -1, &dbps, NULL);
sqlite3_bind_text(dbps, 1, [userContent UTF8String], -1, SQLITE_TRANSIENT);
dbrc = sqlite3_step(dbps);
if (SQLITE_DONE != dbrc) {
// handle error
}
sqlite3_finalize (dbps);
sqlite3_close(db);
你能指點我一些文檔,證明`sqlite3_bind_text`函數是安全的SQL注入攻擊嗎?我沒有在文檔中發現綁定會過濾一些字符的提示嗎? (http://www.sqlite.org/c3ref/bind_blob.html) – 2017-06-09 15:08:18