Skip to content

Commit 7583925

Browse files
committed
CDRIVER-1038 fix cursor for big-endian
Bug in unreleased 1.3.0 code, caused by misinterpreting little-endian wire protocol header data. Introduced during my cursor refactoring for find and getMore commands in MongoDB 3.2.
1 parent a91267c commit 7583925

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/mongoc/mongoc-cursor.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ _mongoc_cursor_op_query (mongoc_cursor_t *cursor,
425425
GOTO (failure);
426426
}
427427

428-
request_id = BSON_UINT32_FROM_LE(rpc.header.request_id);
428+
request_id = BSON_UINT32_FROM_LE (rpc.header.request_id);
429429

430430
_mongoc_buffer_clear(&cursor->buffer, false);
431431

@@ -450,7 +450,7 @@ _mongoc_cursor_op_query (mongoc_cursor_t *cursor,
450450
bson_set_error (&cursor->error,
451451
MONGOC_ERROR_PROTOCOL,
452452
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
453-
"Invalid response_to. Expected %d, got %d.",
453+
"Invalid response_to for query. Expected %d, got %d.",
454454
request_id, cursor->rpc.header.response_to);
455455
GOTO (failure);
456456
}
@@ -831,7 +831,7 @@ _mongoc_cursor_op_getmore (mongoc_cursor_t *cursor,
831831
ENTRY;
832832

833833
if (cursor->in_exhaust) {
834-
request_id = BSON_UINT32_FROM_LE (cursor->rpc.header.request_id);
834+
request_id = (uint32_t) cursor->rpc.header.request_id;
835835
} else {
836836
rpc.get_more.cursor_id = cursor->rpc.reply.cursor_id;
837837
rpc.get_more.msg_len = 0;
@@ -852,7 +852,7 @@ _mongoc_cursor_op_getmore (mongoc_cursor_t *cursor,
852852
GOTO (done);
853853
}
854854

855-
request_id = BSON_UINT32_FROM_LE(rpc.header.request_id);
855+
request_id = BSON_UINT32_FROM_LE (rpc.header.request_id);
856856
}
857857

858858
_mongoc_buffer_clear (&cursor->buffer, false);
@@ -878,7 +878,7 @@ _mongoc_cursor_op_getmore (mongoc_cursor_t *cursor,
878878
bson_set_error (&cursor->error,
879879
MONGOC_ERROR_PROTOCOL,
880880
MONGOC_ERROR_PROTOCOL_INVALID_REPLY,
881-
"Invalid response_to. Expected %d, got %d.",
881+
"Invalid response_to for getmore. Expected %d, got %d.",
882882
request_id, cursor->rpc.header.response_to);
883883
GOTO (done);
884884
}

0 commit comments

Comments
 (0)