Check Rust blob length before binding.

This commit is contained in:
Gwenael Treguier 2015-08-06 21:45:54 +02:00
parent 7b8051dc7e
commit 9c63b9f37a

View File

@ -122,6 +122,9 @@ impl ToSql for String {
impl<'a> ToSql for &'a [u8] {
unsafe fn bind_parameter(&self, stmt: *mut sqlite3_stmt, col: c_int) -> c_int {
if self.len() > ::std::i32::MAX as usize {
return ffi::SQLITE_TOOBIG;
}
ffi::sqlite3_bind_blob(
stmt, col, mem::transmute(self.as_ptr()), self.len() as c_int, ffi::SQLITE_TRANSIENT())
}