@@ -77,7 +77,7 @@ mongoc_apm_command_started_init (mongoc_apm_command_started_t *event,
77
77
const mongoc_host_list_t * host ,
78
78
uint32_t server_id ,
79
79
const bson_oid_t * service_id ,
80
- int32_t server_connection_id ,
80
+ int64_t server_connection_id ,
81
81
bool * is_redacted , /* out */
82
82
void * context )
83
83
{
@@ -208,7 +208,7 @@ mongoc_apm_command_succeeded_init (mongoc_apm_command_succeeded_t *event,
208
208
const mongoc_host_list_t * host ,
209
209
uint32_t server_id ,
210
210
const bson_oid_t * service_id ,
211
- int32_t server_connection_id ,
211
+ int64_t server_connection_id ,
212
212
bool force_redaction ,
213
213
void * context )
214
214
{
@@ -271,7 +271,7 @@ mongoc_apm_command_failed_init (mongoc_apm_command_failed_t *event,
271
271
const mongoc_host_list_t * host ,
272
272
uint32_t server_id ,
273
273
const bson_oid_t * service_id ,
274
- int32_t server_connection_id ,
274
+ int64_t server_connection_id ,
275
275
bool force_redaction ,
276
276
void * context )
277
277
{
@@ -390,7 +390,12 @@ int32_t
390
390
mongoc_apm_command_started_get_server_connection_id (
391
391
const mongoc_apm_command_started_t * event )
392
392
{
393
- return event -> server_connection_id ;
393
+ if (event -> server_connection_id > INT32_MAX ||
394
+ event -> server_connection_id < INT32_MIN ) {
395
+ return MONGOC_NO_SERVER_CONNECTION_ID ;
396
+ }
397
+
398
+ return (int32_t ) event -> server_connection_id ;
394
399
}
395
400
396
401
@@ -477,7 +482,12 @@ int32_t
477
482
mongoc_apm_command_succeeded_get_server_connection_id (
478
483
const mongoc_apm_command_succeeded_t * event )
479
484
{
480
- return event -> server_connection_id ;
485
+ if (event -> server_connection_id > INT32_MAX ||
486
+ event -> server_connection_id < INT32_MIN ) {
487
+ return MONGOC_NO_SERVER_CONNECTION_ID ;
488
+ }
489
+
490
+ return (int32_t ) event -> server_connection_id ;
481
491
}
482
492
483
493
@@ -568,7 +578,12 @@ int32_t
568
578
mongoc_apm_command_failed_get_server_connection_id (
569
579
const mongoc_apm_command_failed_t * event )
570
580
{
571
- return event -> server_connection_id ;
581
+ if (event -> server_connection_id > INT32_MAX ||
582
+ event -> server_connection_id < INT32_MIN ) {
583
+ return MONGOC_NO_SERVER_CONNECTION_ID ;
584
+ }
585
+
586
+ return (int32_t ) event -> server_connection_id ;
572
587
}
573
588
574
589
0 commit comments