[GODRIVER-1506] Extended JSON parsing doesn't restrict $timestamp fields to uint32 Created: 01/Mar/20  Updated: 28/Oct/23  Resolved: 17/Mar/20

Status: Closed
Project: Go Driver
Component/s: JSON & ExtJSON
Affects Version/s: None
Fix Version/s: 1.3.2

Type: Bug Priority: Major - P3
Reporter: David Golden Assignee: Divjot Arora (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

These parse without error:

{"":{"$timestamp":{"i":237239125626700000, "t":0}}}
{"":{"$timestamp":{"i":0,"t":416100000000} } }



 Comments   
Comment by Githook User [ 17/Mar/20 ]

Author:

{'email': 'divjot.arora@10gen.com', 'name': 'Divjot Arora', 'username': 'divjotarora'}

Message: GODRIVER-1506 Fix error checking for invalid extjson timestamp values (#337)
Branch: release/1.3
https://github.com/mongodb/mongo-go-driver/commit/7b305c632d02a9509593593e2cda18daf8981206

Comment by Githook User [ 17/Mar/20 ]

Author:

{'name': 'Divjot Arora', 'username': 'divjotarora', 'email': 'divjot.arora@10gen.com'}

Message: GODRIVER-1506 Fix error checking for invalid extjson timestamp values (#337)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/5262a762f24f78b4f05cc4c8be40fda103728a2b

Comment by Divjot Arora (Inactive) [ 16/Mar/20 ]

https://github.com/mongodb/mongo-go-driver/pull/337

Comment by David Golden [ 03/Mar/20 ]

Also, this crashes:

{"":{"$timestamp":{"t":0,"i":-2800000000}}
panic: interface conversion: interface {} is int64, not int32
 
goroutine 1 [running]:
go.mongodb.org/mongo-driver/bson/bsonrw.(*extJSONValue).parseTimestamp.func1(0x86e2e9, 0x1, 0xc00000cd60, 0x0, 0x0, 0x0, 0x0)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/bsonrw/extjson_wrappers.go:440 +0x61b
go.mongodb.org/mongo-driver/bson/bsonrw.(*extJSONValue).parseTimestamp(0xc00000cdc0, 0x5f5211, 0xc00000cdc0, 0x0)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/bsonrw/extjson_wrappers.go:464 +0x4e2
go.mongodb.org/mongo-driver/bson/bsonrw.(*extJSONValueReader).ReadTimestamp(0xc0000cf470, 0x40ba11, 0xc000102690, 0xc000117940)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/bsonrw/extjson_reader.go:591 +0x121
go.mongodb.org/mongo-driver/bson/bsonrw.Copier.CopyValue(0x703900, 0xc000102690, 0x7039e0, 0xc0000cf470, 0xc000102690, 0x0)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/bsonrw/copier.go:295 +0xe16
go.mongodb.org/mongo-driver/bson/bsonrw.Copier.copyDocumentCore(0x6fe7a0, 0xc000102690, 0x6fdd60, 0xc0000cf470, 0x0, 0x69cc00)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/bsonrw/copier.go:382 +0x1b9
go.mongodb.org/mongo-driver/bson/bsonrw.Copier.CopyDocument(0x703900, 0xc000102690, 0x7039e0, 0xc0000cf470, 0x0, 0xc00000cb00)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/bsonrw/copier.go:45 +0x14b
go.mongodb.org/mongo-driver/bson/bsonrw.Copier.AppendDocumentBytes(0x8a6a40, 0x0, 0x0, 0x7039e0, 0xc0000cf470, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/bsonrw/copier.go:131 +0x27c
go.mongodb.org/mongo-driver/bson.PrimitiveCodecs.RawDecodeValue(0xc00011e1c0, 0xc000117c00, 0x0, 0x0, 0x7039e0, 0xc0000cf470, 0x69e920, 0xc00000cb00, 0x197, 0x62bbc4, ...)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/primitive_codecs.go:86 +0x316
go.mongodb.org/mongo-driver/bson/bsoncodec.ValueDecoderFunc.DecodeValue(0xc00001ce70, 0xc00011e1c0, 0x69e900, 0x0, 0x0, 0x7039e0, 0xc0000cf470, 0x69e920, 0xc00000cb00, 0x197, ...)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/bsoncodec/bsoncodec.go:156 +0xb0
go.mongodb.org/mongo-driver/bson.(*Decoder).Decode(0xc0000cf4a0, 0x69e4c0, 0xc00000cb00, 0xc000117d78, 0x6fd980)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/decoder.go:98 +0x474
go.mongodb.org/mongo-driver/bson.unmarshalFromReader(0xc00011e1c0, 0xc0000cf400, 0x0, 0x0, 0x7039e0, 0xc0000cf470, 0x69e4c0, 0xc00000cb00, 0x0, 0x0)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/unmarshal.go:100 +0x1cb
go.mongodb.org/mongo-driver/bson.UnmarshalExtJSONWithRegistry(0xc00011e1c0, 0x7f16c5123000, 0x2a, 0x2a, 0xc000117e00, 0x69e4c0, 0xc00000cb00, 0x1de3646c, 0x9c67f3f30ea57)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/unmarshal.go:72 +0x194
go.mongodb.org/mongo-driver/bson.UnmarshalExtJSON(...)
        /home/xdg/golang/pkg/mod/go.mongodb.org/mongo-driver@v1.3.0/bson/unmarshal.go:60
github.com/xdg-go/jibby/testdata/fuzzing.FuzzCrashDriver(0x7f16c5123000, 0x2a, 0x2a, 0x4)
        /home/xdg/git/golang/jibby/testdata/fuzzing/fuzz.go:34 +0xa9
go-fuzz-dep.Main(0xc000117f30, 0x4, 0x4)
        go-fuzz-dep/main.go:36 +0x1ad
main.main()
        github.com/xdg-go/jibby/testdata/fuzzing/go.fuzz.main/main.go:21 +0x7a
exit status 2

Generated at Thu Feb 08 08:36:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.