Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
822b476
add sqlite_dbstat tag for the DBSTAT virtual table
calmh May 20, 2025
904664d
avoid out of bounds write in unlock_notify_wait on 64 bit platforms
calmh May 19, 2026
fed9970
modernise reflect.SliceHeader to unsafe.Slice
calmh May 19, 2026
9d6bf2c
Merge pull request #1338 from calmh/dbstat
mattn May 23, 2026
9accb92
Merge pull request #1399 from calmh/uintsize
mattn Jun 2, 2026
1a7264c
Merge pull request #1400 from calmh/unsafereflect
mattn Jun 2, 2026
2af23f7
guard oversized string length in ResultText
dxbjavid Jun 3, 2026
b3b5216
Merge pull request #1402 from dxbjavid/guard-resulttext-oversize
mattn Jun 3, 2026
d1ab49c
bind via sqlite3_bind_text64/blob64 to avoid 32-bit length truncation
dxbjavid Jun 5, 2026
75d8c60
Merge pull request #1403 from dxbjavid/bind-text64-length
mattn Jun 5, 2026
e2ab931
Upgrade SQLite to version 3053002
mattn Jun 5, 2026
7ca6a97
Merge pull request #1404 from mattn/sqlite-amalgamation-3053002
mattn Jun 5, 2026
78b95b7
Clean up accidental v2 references
mattn Jun 5, 2026
5f1e21d
guard oversized blob length in callbackRetBlob
dxbjavid Jun 5, 2026
c63653b
Merge pull request #1405 from dxbjavid/oversize-blob-result-guard
mattn Jun 6, 2026
6b68c20
preserve embedded NUL bytes in custom function text values
dxbjavid Jun 9, 2026
b1e8d68
read text value before its byte length to match documented order
dxbjavid Jun 9, 2026
518ffdb
Merge pull request #1406 from dxbjavid/function-text-embedded-nul
mattn Jun 9, 2026
c3e96cd
call sqlite3_value_blob before sqlite3_value_bytes in callbackArgString
mattn Jun 9, 2026
379319c
Merge pull request #1407 from mattn/blob-arg-call-order
mattn Jun 9, 2026
bed93d5
Merge remote-tracking branch 'mattn/master' into merge-upstream
otoolep Jun 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package sqlite3
#endif
#include <stdlib.h>

void _sqlite3_result_text(sqlite3_context* ctx, const char* s);
void _sqlite3_result_text(sqlite3_context* ctx, const char* s, int n);
void _sqlite3_result_blob(sqlite3_context* ctx, const void* b, int l);
*/
import "C"
Expand Down Expand Up @@ -204,12 +204,13 @@ func callbackArgBytes(v *C.sqlite3_value) (reflect.Value, error) {
func callbackArgString(v *C.sqlite3_value) (reflect.Value, error) {
switch C.sqlite3_value_type(v) {
case C.SQLITE_BLOB:
l := C.sqlite3_value_bytes(v)
p := (*C.char)(C.sqlite3_value_blob(v))
l := C.sqlite3_value_bytes(v)
return reflect.ValueOf(C.GoStringN(p, l)), nil
case C.SQLITE_TEXT:
c := (*C.char)(unsafe.Pointer(C.sqlite3_value_text(v)))
return reflect.ValueOf(C.GoString(c)), nil
l := C.sqlite3_value_bytes(v)
return reflect.ValueOf(C.GoStringN(c, l)), nil
default:
return reflect.Value{}, fmt.Errorf("argument must be BLOB or TEXT")
}
Expand Down Expand Up @@ -336,6 +337,10 @@ func callbackRetBlob(ctx *C.sqlite3_context, v reflect.Value) error {
C.sqlite3_result_null(ctx)
} else {
bs := i.([]byte)
if i64 && len(bs) > math.MaxInt32 {
C.sqlite3_result_error_toobig(ctx)
return nil
}
C._sqlite3_result_blob(ctx, unsafe.Pointer(&bs[0]), C.int(len(bs)))
}
return nil
Expand All @@ -345,8 +350,13 @@ func callbackRetText(ctx *C.sqlite3_context, v reflect.Value) error {
if v.Type().Kind() != reflect.String {
return fmt.Errorf("cannot convert %s to TEXT", v.Type())
}
cstr := C.CString(v.Interface().(string))
C._sqlite3_result_text(ctx, cstr)
s := v.Interface().(string)
if i64 && len(s) > math.MaxInt32 {
C.sqlite3_result_error_toobig(ctx)
return nil
}
cstr := C.CString(s)
C._sqlite3_result_text(ctx, cstr, C.int(len(s)))
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module github.com/rqlite/go-sqlite3
go 1.21

retract (
[v2.0.0+incompatible, v2.0.6+incompatible] // Accidental; no major changes or features.
[v2.0.0+incompatible, v2.0.7+incompatible] // Accidental; no major changes or features.
)
Loading
Loading