Skip to content

Commit c34137f

Browse files
committed
updates
1 parent 40319b3 commit c34137f

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

bson/bsoncodec/uint_codec.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,9 @@ func (uic *UIntCodec) decodeType(dc DecodeContext, vr bsonrw.ValueReader, t refl
164164

165165
return reflect.ValueOf(uint64(i64)), nil
166166
case reflect.Uint:
167-
if i64 < 0 || uint64(i64) > uint64(math.MaxUint) { // Can we fit this inside of an uint
167+
if i64 < 0 || int64(uint(i64)) != i64 { // Can we fit this inside of an uint
168168
return emptyValue, fmt.Errorf("%d overflows uint", i64)
169169
}
170-
171170
return reflect.ValueOf(uint(i64)), nil
172171
default:
173172
return emptyValue, ValueDecoderError{

etc/run-atlas-test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ set +x
88
. ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/atlas_connect
99

1010
echo "Running cmd/testatlas"
11-
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
11+
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

x/bsonx/bsoncore/bsoncore.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -707,17 +707,16 @@ func ReserveLength(dst []byte) (int32, []byte) {
707707

708708
// UpdateLength updates the length at index with length and returns the []byte.
709709
func UpdateLength(dst []byte, index, length int32) []byte {
710-
dst[index] = byte(length)
711-
dst[index+1] = byte(length >> 8)
712-
dst[index+2] = byte(length >> 16)
713-
dst[index+3] = byte(length >> 24)
710+
binary.LittleEndian.PutUint32(dst[index:], uint32(length))
714711
return dst
715712
}
716713

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

719716
func appendi32(dst []byte, i32 int32) []byte {
720-
return append(dst, byte(i32), byte(i32>>8), byte(i32>>16), byte(i32>>24))
717+
b := []byte{0, 0, 0, 0}
718+
binary.LittleEndian.PutUint32(b, uint32(i32))
719+
return append(dst, b...)
721720
}
722721

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

0 commit comments

Comments
 (0)