Merge pull request #62 from gwenn/too-big

Check Rust str length before binding.
This commit is contained in:
John Gallagher
2015-09-20 20:57:28 -04:00
2 changed files with 14 additions and 1 deletions

View File

@@ -543,6 +543,12 @@ impl InnerSqliteConnection {
fn prepare<'a>(&mut self,
conn: &'a SqliteConnection,
sql: &str) -> SqliteResult<SqliteStatement<'a>> {
if sql.len() >= ::std::i32::MAX as usize {
return Err(SqliteError {
code: ffi::SQLITE_TOOBIG,
message: "statement too long".to_string()
});
}
let mut c_stmt: *mut ffi::sqlite3_stmt = unsafe { mem::uninitialized() };
let c_sql = try!(str_to_cstring(sql));
let r = unsafe {