Skip to content

Commit 7df73e0

Browse files
committed
Blob I/O: limit and expose blob size
1 parent 893e77d commit 7df73e0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

blob_io.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,20 @@ func (s *SQLiteBlob) Seek(offset int64, whence int) (int64, error) {
128128
return 0, errors.New("sqlite.SQLiteBlob.Seek: negative position")
129129
}
130130

131+
if abs > math.MaxInt32 {
132+
return 0, errors.New("sqlite3.SQLiteBlob.Seek: overflow position")
133+
}
134+
131135
s.offset = int(abs)
132136

133137
return abs, nil
134138
}
135139

140+
// Size returns the size of the blob.
141+
func (s *SQLiteBlob) Size() int {
142+
return s.size
143+
}
144+
136145
// Close implements the io.Closer interface.
137146
func (s *SQLiteBlob) Close() error {
138147
ret := C.sqlite3_blob_close(s.blob)

0 commit comments

Comments
 (0)