summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3/vfs/cksm.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2025-04-04 15:34:38 +0000
committerLibravatar GitHub <noreply@github.com>2025-04-04 17:34:38 +0200
commitdb4b85715966ee590c6cdff5cc52e592b66e3d17 (patch)
tree83642d3afe51fbe279e36a9a6c9069f785a0adeb /vendor/github.com/ncruces/go-sqlite3/vfs/cksm.go
parent[bugfix] Fix Atkinson Hyperlegible font embedding on Ecks Pee theme. (#3964) (diff)
downloadgotosocial-db4b85715966ee590c6cdff5cc52e592b66e3d17.tar.xz
[chore] bump ncruces/go-sqlite3 to v0.25.0 (#3966)
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/vfs/cksm.go')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/vfs/cksm.go24
1 files changed, 15 insertions, 9 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/vfs/cksm.go b/vendor/github.com/ncruces/go-sqlite3/vfs/cksm.go
index 041defec3..0ff7b6f18 100644
--- a/vendor/github.com/ncruces/go-sqlite3/vfs/cksm.go
+++ b/vendor/github.com/ncruces/go-sqlite3/vfs/cksm.go
@@ -49,9 +49,7 @@ func (c cksmFile) ReadAt(p []byte, off int64) (n int, err error) {
n, err = c.File.ReadAt(p, off)
p = p[:n]
- // SQLite is reading the header of a database file.
- if c.isDB && off == 0 && len(p) >= 100 &&
- bytes.HasPrefix(p, []byte("SQLite format 3\000")) {
+ if isHeader(c.isDB, p, off) {
c.init((*[100]byte)(p))
}
@@ -67,9 +65,7 @@ func (c cksmFile) ReadAt(p []byte, off int64) (n int, err error) {
}
func (c cksmFile) WriteAt(p []byte, off int64) (n int, err error) {
- // SQLite is writing the first page of a database file.
- if c.isDB && off == 0 && len(p) >= 100 &&
- bytes.HasPrefix(p, []byte("SQLite format 3\000")) {
+ if isHeader(c.isDB, p, off) {
c.init((*[100]byte)(p))
}
@@ -116,9 +112,11 @@ func (c cksmFile) fileControl(ctx context.Context, mod api.Module, op _FcntlOpco
c.inCkpt = true
case _FCNTL_CKPT_DONE:
c.inCkpt = false
- }
- if rc := vfsFileControlImpl(ctx, mod, c, op, pArg); rc != _NOTFOUND {
- return rc
+ case _FCNTL_PRAGMA:
+ rc := vfsFileControlImpl(ctx, mod, c, op, pArg)
+ if rc != _NOTFOUND {
+ return rc
+ }
}
return vfsFileControlImpl(ctx, mod, c.File, op, pArg)
}
@@ -135,6 +133,14 @@ func (f *cksmFlags) init(header *[100]byte) {
}
}
+func isHeader(isDB bool, p []byte, off int64) bool {
+ check := sql3util.ValidPageSize(len(p))
+ if isDB {
+ check = off == 0 && len(p) >= 100
+ }
+ return check && bytes.HasPrefix(p, []byte("SQLite format 3\000"))
+}
+
func cksmCompute(a []byte) (cksm [8]byte) {
var s1, s2 uint32
for len(a) >= 8 {