Closed zellyn closed 6 years ago
@zellyn I think I fixed this particular panic in 81ef595. could you confirm ?
The panic at github.com/sbinet/sqlite3/page.go:138 moves to github.com/sbinet/sqlite3/page.go:144, but otherwise the error remains unchanged.
Actually, that's not true. The NFileChanges:429337
changes to NFileChanges:429338
, and the VersionValid:429337
changes to VersionValid:429338
.
What OS are you on? If you can find your Chrome cookie database, you can probably reproduce it yourself easily. Here's the whole program I'm running to reproduce it:
package main
import (
"fmt"
"os"
"os/user"
"github.com/sbinet/sqlite3"
)
func run() error {
usr, _ := user.Current()
cookiesFile := fmt.Sprintf("%s/Library/Application Support/Google/Chrome/Default/Cookies", usr.HomeDir)
db, err := sqlite3.Open(cookiesFile)
if err != nil {
return err
}
defer db.Close()
for _, table := range db.Tables() {
fmt.Printf(">>> table=%#v\n", table)
}
return nil
}
func main() {
if err := run(); err != nil {
fmt.Fprintf(os.Stderr, "Got error: %v", err)
}
}
I am on Linux.
this worked for me:
$> go run ./n.go /home/binet/.config/chromium/Default/Cookies
db: sqlite3.dbHeader{Magic:[16]uint8{0x53, 0x51, 0x4c, 0x69, 0x74, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x20, 0x33, 0x0}, PageSize:0x400, WVersion:0x1, RVersion:0x1, NReserved:0x0, MaxFraction:0x40, MinFraction:0x20, LeafFraction:0x20, NFileChanges:6067689, DbSize:4802, FreePage:2084, NFreePages:3750, SchemaCookie:[4]uint8{0x0, 0x0, 0x0, 0x7}, SchemaFormat:3, PageCacheSize:0, AutoVacuum:0, DbEncoding:1, UserVersion:0, IncrVacuum:0, ApplicationID:0, XXX_reserved:[20]uint8{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, VersionValid:6067689, SqliteVersion:3020000}
>>> bt-hdr: sqlite3.btheader{raw:struct { Kind sqlite3.PageKind; FreeBlockOffset int16; NCells int16; CellsOffset int16; NFreeBytes int8 }{Kind:0xd, FreeBlockOffset:0, NCells:6, CellsOffset:193, NFreeBytes:0}}
>>> init... (ncells=6)
>>> def: "key LONGVARCHAR NOT NULL UNIQUE PRIMARY KEY, value LONGVARCHAR" => ncols=2
2017/12/01 16:12:16 **WARNING** decoding overflow-page not implemented
>>> def: "creation_utc INTEGER NOT NULL UNIQUE PRIMARY KEY,host_key TEXT NOT NULL,name TEXT NOT NULL,value TEXT NOT NULL,path TEXT N" => ncols=5
>>> table=sqlite3.Table{name:"meta", pageid:2, cols:[]sqlite3.Column{sqlite3.Column{name:"", typ:reflect.Type(nil)}, sqlite3.Column{name:"", typ:reflect.Type(nil)}}}
>>> table=sqlite3.Table{name:"cookies", pageid:4, cols:[]sqlite3.Column{sqlite3.Column{name:"", typ:reflect.Type(nil)}, sqlite3.Column{name:"", typ:reflect.Type(nil)}, sqlite3.Column{name:"", typ:reflect.Type(nil)}, sqlite3.Column{name:"", typ:reflect.Type(nil)}, sqlite3.Column{name:"", typ:reflect.Type(nil)}}}
Oh lovely. :-)
I created a new user, logged in to one site, then closed the window. Here's the cookie file. Does that work or break for you?
ok. now I can reproduce :)
Heh. I know this is ancient code, but thought you might like to know. I'm trying to port this cookie-reading code to your go-native sqlite3 reader, since compiling and linking the full sqlite implementation for such a simple query is overkill.
But just opening the database fails. Here's what I'm trying:
I get this panic:
Not sure if you'd still care, or have enough context to debug. :-)
Oh, Mac OS High Sierra, fwiw.