@@ -89,9 +89,9 @@ mcon_str *bson_create_ping_packet(mongo_connection *con)
89
89
mcon_str_addl (str , "" , 1 , 0 ); /* Trailing 0x00 */
90
90
91
91
/* Set length */
92
- ((int * ) (& (str -> d [hdr ])))[0 ] = str -> l - hdr ;
92
+ ((int * ) (& (str -> d [hdr ])))[0 ] = MONGO_32 ( str -> l - hdr ) ;
93
93
94
- ((int * ) str -> d )[0 ] = str -> l ;
94
+ ((int * ) str -> d )[0 ] = MONGO_32 ( str -> l ) ;
95
95
return str ;
96
96
}
97
97
@@ -106,9 +106,9 @@ mcon_str *bson_create_ismaster_packet(mongo_connection *con)
106
106
mcon_str_addl (str , "" , 1 , 0 ); /* Trailing 0x00 */
107
107
108
108
/* Set length */
109
- ((int * ) (& (str -> d [hdr ])))[0 ] = str -> l - hdr ;
109
+ ((int * ) (& (str -> d [hdr ])))[0 ] = MONGO_32 ( str -> l - hdr ) ;
110
110
111
- ((int * ) str -> d )[0 ] = str -> l ;
111
+ ((int * ) str -> d )[0 ] = MONGO_32 ( str -> l ) ;
112
112
return str ;
113
113
}
114
114
@@ -123,9 +123,9 @@ mcon_str *bson_create_buildinfo_packet(mongo_connection *con)
123
123
mcon_str_addl (str , "" , 1 , 0 ); /* Trailing 0x00 */
124
124
125
125
/* Set length */
126
- ((int * ) (& (str -> d [hdr ])))[0 ] = str -> l - hdr ;
126
+ ((int * ) (& (str -> d [hdr ])))[0 ] = MONGO_32 ( str -> l - hdr ) ;
127
127
128
- ((int * ) str -> d )[0 ] = str -> l ;
128
+ ((int * ) str -> d )[0 ] = MONGO_32 ( str -> l ) ;
129
129
return str ;
130
130
}
131
131
@@ -140,9 +140,9 @@ mcon_str *bson_create_rs_status_packet(mongo_connection *con)
140
140
mcon_str_addl (str , "" , 1 , 0 ); /* Trailing 0x00 */
141
141
142
142
/* Set length */
143
- ((int * ) (& (str -> d [hdr ])))[0 ] = str -> l - hdr ;
143
+ ((int * ) (& (str -> d [hdr ])))[0 ] = MONGO_32 ( str -> l - hdr ) ;
144
144
145
- ((int * ) str -> d )[0 ] = str -> l ;
145
+ ((int * ) str -> d )[0 ] = MONGO_32 ( str -> l ) ;
146
146
return str ;
147
147
}
148
148
@@ -157,9 +157,9 @@ mcon_str *bson_create_getnonce_packet(mongo_connection *con)
157
157
mcon_str_addl (str , "" , 1 , 0 ); /* Trailing 0x00 */
158
158
159
159
/* Set length */
160
- ((int * ) (& (str -> d [hdr ])))[0 ] = str -> l - hdr ;
160
+ ((int * ) (& (str -> d [hdr ])))[0 ] = MONGO_32 ( str -> l - hdr ) ;
161
161
162
- ((int * ) str -> d )[0 ] = str -> l ;
162
+ ((int * ) str -> d )[0 ] = MONGO_32 ( str -> l ) ;
163
163
return str ;
164
164
}
165
165
@@ -194,9 +194,9 @@ mcon_str *bson_create_authenticate_packet(mongo_connection *con, char *mechanism
194
194
mcon_str_addl (str , "" , 1 , 0 ); /* Trailing 0x00 */
195
195
196
196
/* Set length */
197
- ((int * ) (& (str -> d [hdr ])))[0 ] = str -> l - hdr ;
197
+ ((int * ) (& (str -> d [hdr ])))[0 ] = MONGO_32 ( str -> l - hdr ) ;
198
198
199
- ((int * ) str -> d )[0 ] = str -> l ;
199
+ ((int * ) str -> d )[0 ] = MONGO_32 ( str -> l ) ;
200
200
return str ;
201
201
}
202
202
@@ -229,9 +229,9 @@ mcon_str *bson_create_saslstart_packet(mongo_connection *con, char *database, ch
229
229
mcon_str_addl (str , "" , 1 , 0 ); /* Trailing 0x00 */
230
230
231
231
/* Set length */
232
- ((int * ) (& (str -> d [hdr ])))[0 ] = str -> l - hdr ;
232
+ ((int * ) (& (str -> d [hdr ])))[0 ] = MONGO_32 ( str -> l - hdr ) ;
233
233
234
- ((int * ) str -> d )[0 ] = str -> l ;
234
+ ((int * ) str -> d )[0 ] = MONGO_32 ( str -> l ) ;
235
235
return str ;
236
236
}
237
237
@@ -257,9 +257,9 @@ mcon_str *bson_create_saslcontinue_packet(mongo_connection *con, char *database,
257
257
mcon_str_addl (str , "" , 1 , 0 ); /* Trailing 0x00 */
258
258
259
259
/* Set length */
260
- ((int * ) (& (str -> d [hdr ])))[0 ] = str -> l - hdr ;
260
+ ((int * ) (& (str -> d [hdr ])))[0 ] = MONGO_32 ( str -> l - hdr ) ;
261
261
262
- ((int * ) str -> d )[0 ] = str -> l ;
262
+ ((int * ) str -> d )[0 ] = MONGO_32 ( str -> l ) ;
263
263
return str ;
264
264
}
265
265
@@ -428,7 +428,7 @@ int bson_find_field_as_double(char *buffer, char *field, double *data)
428
428
char * tmp = (char * ) bson_find_field (buffer , field , BSON_DOUBLE );
429
429
430
430
if (tmp ) {
431
- * data = (( double * )tmp )[0 ];
431
+ * data = (double ) MONGO_64 ( (( int64_t * )tmp )[0 ] ) ;
432
432
return 1 ;
433
433
}
434
434
return 0 ;
@@ -450,7 +450,7 @@ int bson_find_field_as_int32(char *buffer, char *field, int32_t *data)
450
450
char * tmp = (char * ) bson_find_field (buffer , field , BSON_INT32 );
451
451
452
452
if (tmp ) {
453
- * data = (( int32_t * )tmp )[0 ];
453
+ * data = MONGO_32 ( (( int32_t * )tmp )[0 ] ) ;
454
454
return 1 ;
455
455
}
456
456
return 0 ;
@@ -461,7 +461,7 @@ int bson_find_field_as_int64(char *buffer, char *field, int64_t *data)
461
461
char * tmp = (char * ) bson_find_field (buffer , field , BSON_INT64 );
462
462
463
463
if (tmp ) {
464
- * data = (( int64_t * )tmp )[0 ];
464
+ * data = MONGO_64 ( (( int64_t * )tmp )[0 ] ) ;
465
465
return 1 ;
466
466
}
467
467
return 0 ;
@@ -472,7 +472,7 @@ int bson_find_field_as_stringl(char *buffer, char *field, char **data, int32_t *
472
472
char * tmp = bson_find_field (buffer , field , BSON_STRING );
473
473
474
474
if (tmp ) {
475
- * length = (( int32_t * )tmp )[0 ];
475
+ * length = MONGO_32 ( (( int32_t * )tmp )[0 ] ) ;
476
476
* data = duplicate ? strdup (tmp + 4 ) : tmp + 4 ; /* int32 for length */
477
477
return 1 ;
478
478
}
@@ -515,7 +515,7 @@ int bson_array_find_next_int32(char **buffer, char **field, int32_t *data)
515
515
516
516
return_data = bson_get_current (* buffer , & read_field , & read_type );
517
517
if (read_type == BSON_INT32 ) {
518
- * data = (( int32_t * ) return_data )[0 ];
518
+ * data = MONGO_32 ( (( int32_t * ) return_data )[0 ] ) ;
519
519
if (field ) {
520
520
* field = strdup (read_field );
521
521
}
0 commit comments