@@ -77,7 +77,7 @@ mongoc_apm_command_started_init (mongoc_apm_command_started_t *event,
7777 const mongoc_host_list_t * host ,
7878 uint32_t server_id ,
7979 const bson_oid_t * service_id ,
80- int32_t server_connection_id ,
80+ int64_t server_connection_id ,
8181 bool * is_redacted , /* out */
8282 void * context )
8383{
@@ -208,7 +208,7 @@ mongoc_apm_command_succeeded_init (mongoc_apm_command_succeeded_t *event,
208208 const mongoc_host_list_t * host ,
209209 uint32_t server_id ,
210210 const bson_oid_t * service_id ,
211- int32_t server_connection_id ,
211+ int64_t server_connection_id ,
212212 bool force_redaction ,
213213 void * context )
214214{
@@ -271,7 +271,7 @@ mongoc_apm_command_failed_init (mongoc_apm_command_failed_t *event,
271271 const mongoc_host_list_t * host ,
272272 uint32_t server_id ,
273273 const bson_oid_t * service_id ,
274- int32_t server_connection_id ,
274+ int64_t server_connection_id ,
275275 bool force_redaction ,
276276 void * context )
277277{
@@ -390,7 +390,12 @@ int32_t
390390mongoc_apm_command_started_get_server_connection_id (
391391 const mongoc_apm_command_started_t * event )
392392{
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 ;
394399}
395400
396401
@@ -477,7 +482,12 @@ int32_t
477482mongoc_apm_command_succeeded_get_server_connection_id (
478483 const mongoc_apm_command_succeeded_t * event )
479484{
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 ;
481491}
482492
483493
@@ -568,7 +578,12 @@ int32_t
568578mongoc_apm_command_failed_get_server_connection_id (
569579 const mongoc_apm_command_failed_t * event )
570580{
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 ;
572587}
573588
574589
0 commit comments