Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Jun 26, 2024
1 parent 40319b3 commit 27f5ac7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bson/bsoncodec/uint_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (uic *UIntCodec) decodeType(dc DecodeContext, vr bsonrw.ValueReader, t refl
return emptyValue, fmt.Errorf("%d overflows uint", i64)
}

return reflect.ValueOf(uint(i64)), nil
return reflect.ValueOf(uint(uint64(i64))), nil

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

Incorrect conversion of a signed 64-bit integer from
strconv.ParseInt
to a lower bit size type uint without an upper bound check.
Incorrect conversion of a signed 64-bit integer from
strconv.ParseInt
to a lower bit size type uint without an upper bound check.
default:
return emptyValue, ValueDecoderError{
Name: "UintDecodeValue",
Expand Down
2 changes: 1 addition & 1 deletion etc/run-atlas-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ set +x
. ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/atlas_connect

echo "Running cmd/testatlas"
go test -run ^TestAtlas$ go.mongodb.org/mongo-driver/cmd/testatlas -args "$ATLAS_REPL" "$ATLAS_SHRD" "$ATLAS_FREE" "$ATLAS_TLS11" "$ATLAS_TLS12" "$ATLAS_SERVERLESS" "$ATLAS_SRV_REPL" "$ATLAS_SRV_SHRD" "$ATLAS_SRV_FREE" "$ATLAS_SRV_TLS11" "$ATLAS_SRV_TLS12" "$ATLAS_SRV_SERVERLESS" >> test.suite
go test -v -run ^TestAtlas$ go.mongodb.org/mongo-driver/cmd/testatlas -args "$ATLAS_REPL" "$ATLAS_SHRD" "$ATLAS_FREE" "$ATLAS_TLS11" "$ATLAS_TLS12" "$ATLAS_SERVERLESS" "$ATLAS_SRV_REPL" "$ATLAS_SRV_SHRD" "$ATLAS_SRV_FREE" "$ATLAS_SRV_TLS11" "$ATLAS_SRV_TLS12" "$ATLAS_SRV_SERVERLESS" >> test.suite
9 changes: 4 additions & 5 deletions x/bsonx/bsoncore/bsoncore.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,17 +707,16 @@ func ReserveLength(dst []byte) (int32, []byte) {

// UpdateLength updates the length at index with length and returns the []byte.
func UpdateLength(dst []byte, index, length int32) []byte {
dst[index] = byte(length)
dst[index+1] = byte(length >> 8)
dst[index+2] = byte(length >> 16)
dst[index+3] = byte(length >> 24)
binary.LittleEndian.PutUint32(dst[index:], uint32(length))
return dst
}

func appendLength(dst []byte, l int32) []byte { return appendi32(dst, l) }

func appendi32(dst []byte, i32 int32) []byte {
return append(dst, byte(i32), byte(i32>>8), byte(i32>>16), byte(i32>>24))
b := []byte{0, 0, 0, 0}
binary.LittleEndian.PutUint32(b, uint32(i32))
return append(dst, b...)
}

// ReadLength reads an int32 length from src and returns the length and the remaining bytes. If
Expand Down

0 comments on commit 27f5ac7

Please sign in to comment.