File tree Expand file tree Collapse file tree
sqlite-wasm-rs/src/shim/vfs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -156,7 +156,16 @@ unsafe extern "C" fn xFullPathname(
156156 nOut : :: std:: os:: raw:: c_int ,
157157 zOut : * mut :: std:: os:: raw:: c_char ,
158158) -> :: std:: os:: raw:: c_int {
159- zName. copy_to ( zOut, nOut as usize ) ;
159+ if zName. is_null ( ) || zOut. is_null ( ) {
160+ return SQLITE_CANTOPEN ;
161+ }
162+ let len = CStr :: from_ptr ( zName) . count_bytes ( ) + 1 ;
163+
164+ if len > nOut as usize {
165+ return SQLITE_CANTOPEN ;
166+ }
167+ zName. copy_to ( zOut, len) ;
168+
160169 SQLITE_OK
161170}
162171
@@ -286,7 +295,7 @@ unsafe extern "C" fn xCheckReservedLock(
286295}
287296
288297unsafe extern "C" fn xFileControl (
289- _pVfs : * mut sqlite3_file ,
298+ _pFile : * mut sqlite3_file ,
290299 _op : :: std:: os:: raw:: c_int ,
291300 _pArg : * mut :: std:: os:: raw:: c_void ,
292301) -> :: std:: os:: raw:: c_int {
Original file line number Diff line number Diff line change @@ -833,7 +833,17 @@ unsafe extern "C" fn xFullPathname(
833833 nOut : :: std:: os:: raw:: c_int ,
834834 zOut : * mut :: std:: os:: raw:: c_char ,
835835) -> :: std:: os:: raw:: c_int {
836- zName. copy_to ( zOut, nOut as usize ) ;
836+ if zName. is_null ( ) || zOut. is_null ( ) {
837+ return SQLITE_CANTOPEN ;
838+ }
839+ let len = CStr :: from_ptr ( zName) . count_bytes ( ) + 1 ;
840+
841+ if len > nOut as usize {
842+ return SQLITE_CANTOPEN ;
843+ }
844+
845+ zName. copy_to ( zOut, len) ;
846+
837847 SQLITE_OK
838848}
839849
You can’t perform that action at this time.
0 commit comments