Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KATC] Do not allow indexeddb row data to be overwritten #1785

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion ee/indexeddb/indexeddb.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,10 @@ func QueryIndexeddbObjectStore(dbLocation string, dbName string, objectStoreName
continue
}

tmp := make([]byte, len(iter.Value()))
copy(tmp, iter.Value())
objs = append(objs, map[string][]byte{
"data": iter.Value(),
"data": tmp,
})
}
iter.Release()
Expand Down
14 changes: 7 additions & 7 deletions ee/indexeddb/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,21 @@ func deserializeObject(srcReader io.ByteReader) (map[string][]byte, error) {
// Object nested inside this object
nestedObj, err := deserializeNestedObject(srcReader)
if err != nil {
return obj, fmt.Errorf("decoding nested object: %w", err)
return obj, fmt.Errorf("decoding nested object for %s: %w", currentPropertyName, err)
}
obj[currentPropertyName] = nestedObj
case tokenAsciiStr:
// ASCII string
strVal, err := deserializeAsciiStr(srcReader)
if err != nil {
return obj, fmt.Errorf("decoding ascii string: %w", err)
return obj, fmt.Errorf("decoding ascii string for %s: %w", currentPropertyName, err)
}
obj[currentPropertyName] = strVal
case tokenUtf16Str:
// UTF-16 string
strVal, err := deserializeUtf16Str(srcReader)
if err != nil {
return obj, fmt.Errorf("decoding ascii string: %w", err)
return obj, fmt.Errorf("decoding ascii string for %s: %w", currentPropertyName, err)
}
obj[currentPropertyName] = strVal
case tokenTrue:
Expand All @@ -176,14 +176,14 @@ func deserializeObject(srcReader io.ByteReader) (map[string][]byte, error) {
case tokenInt32:
propertyInt, err := binary.ReadVarint(srcReader)
if err != nil {
return obj, fmt.Errorf("decoding int32: %w", err)
return obj, fmt.Errorf("decoding int32 for %s: %w", currentPropertyName, err)
}
obj[currentPropertyName] = []byte(strconv.Itoa(int(propertyInt)))
case tokenBeginSparseArray:
// This is the only type of array I've encountered so far, so it's the only one implemented.
arr, err := deserializeSparseArray(srcReader)
if err != nil {
return obj, fmt.Errorf("decoding array: %w", err)
return obj, fmt.Errorf("decoding array for %s: %w", currentPropertyName, err)
}
obj[currentPropertyName] = arr
case tokenPadding, tokenVerifyObjectCount:
Expand Down Expand Up @@ -301,7 +301,7 @@ func deserializeAsciiStr(srcReader io.ByteReader) ([]byte, error) {
for i := 0; i < int(strLen); i += 1 {
nextByte, err := srcReader.ReadByte()
if err != nil {
return nil, fmt.Errorf("reading next byte in string: %w", err)
return nil, fmt.Errorf("reading next byte at index %d in string with length %d: %w", i, strLen, err)
}

strBytes[i] = nextByte
Expand All @@ -321,7 +321,7 @@ func deserializeUtf16Str(srcReader io.ByteReader) ([]byte, error) {
for i := 0; i < int(strLen); i += 1 {
nextByte, err := srcReader.ReadByte()
if err != nil {
return nil, fmt.Errorf("reading next byte in string: %w", err)
return nil, fmt.Errorf("reading next byte at index %d in string with length %d: %w", i, strLen, err)
}

strBytes[i] = nextByte
Expand Down
Loading