Keep the stored bytes when a sign-out unbinds a row whose data is not text
KeyStore::get reads a data column that is a BLOB, or TEXT of bytes that are no UTF-8, as text with the odd bytes replaced. The sign-out's unbind step puts that text back with the binding removed; REBIND (data = ?3) matches nothing for such a row, so put fell through to the full write: the lossy string replaced the original bytes (invalid UTF-8 became U+FFFD, a BLOB became TEXT), and for a TeamSpeak row the replaced text is no identity, so check_teamspeak refused it and the sign-out could never finish for that row. - put() now tries a second statement when REBIND changed nothing: rebind_stored_bytes reads the stored data raw and, if it reads (lossy_text) as exactly the blob's JSON, updates only the four binding columns by (kind, uid) (REBIND_BYTES) and returns without check_teamspeak, so the original bytes are kept and the TeamSpeak case unsticks. Any other JSON is a new identity for the uid, checked and stored as before. - The doc sentences at the top of keystore.rs (what a binding-only put and a non-text data column mean) and docs/architecture.md are narrowed to what holds: the bytes are kept for the text get returned, any other text replaces them. Tests: the gate's probe (a bound voelin row with data x'7b2276223aff317d', two future-kind rows, one a BLOB and one TEXT of no UTF-8, and two TeamSpeak BLOB rows, one of a good identity and one of garbage): sign_out(Auto) and sign_out(Forget) are Ok and every data value is byte-identical afterwards; a put of what get read changes the binding and keeps the bytes; a put of other data is checked and replaces them. The three tests fail on the previous code. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ac4095143
commit
670ed9f29b
3 files changed
+236
-15
No files matched your search
@@ -347,8 +347,13 @@ origin and default flag, a uid another kind holds is refused, a TeamSpeak blob
|
||||
is stored only when its JSON is a tsproto identity whose key has the uid it
|
||||
names (the error says only that, never the JSON: it is a private key), and
|
||||
the TeamSpeak security level is still computed from the key, never stored. A
|
||||
`put` that changes only the binding of a row does not read its JSON again, so a
|
||||
row damaged outside the client cannot keep a sign-out from unbinding it.
|
||||
`put` that changes only the binding of a row (its data is what `get` read from
|
||||
the row) neither checks nor rewrites the data, so a row whose data was damaged
|
||||
outside the client (JSON that is no identity, a BLOB, bytes that are no UTF-8)
|
||||
cannot keep a sign-out from unbinding it, and keeps its data byte for byte.
|
||||
`get` hands such data out as text with the odd bytes replaced, and the `put` of
|
||||
that text is taken for the data that is there; any other text is a new identity
|
||||
for the uid, checked as ever, and replaces the bytes.
|
||||
A row whose binding columns cannot be read is listed and read as unbound, with a
|
||||
warning, instead of failing the list; so no damaged row, the account record's
|
||||
included, keeps a sign-out from finishing, and `Forget` still deletes the key
|
||||
|
||||
Reference in new issue
Block a user