Skip to content

Commit

Permalink
[KATC] Do not allow indexeddb row data to be overwritten (#1785)
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany authored Jul 17, 2024
1 parent 5a86aab commit 7c5ce6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
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

0 comments on commit 7c5ce6a

Please sign in to comment.