-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix: prevent signed integer overflow in OP_MSG message sizes #2693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2a0304e
e5cdb2e
acc3f21
3211211
f170513
ef64bbf
5201951
077648c
4d57f95
bba20d2
e252ccc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -60,7 +60,7 @@ static PyObject* _error(char* name) { | |||||||
| * Returns 0 on failure */ | ||||||||
| static int buffer_write_bytes_ssize_t(buffer_t buffer, const char* data, Py_ssize_t size) { | ||||||||
| int downsize = _downcast_and_check(size, 0); | ||||||||
| if (size == -1) { | ||||||||
HyperPS marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| if (downsize == -1) { | ||||||||
| return 0; | ||||||||
| } | ||||||||
| return buffer_write_bytes(buffer, data, downsize); | ||||||||
|
Comment on lines
61
to
66
|
||||||||
|
|
@@ -333,7 +333,6 @@ static PyObject* _cbson_op_msg(PyObject* self, PyObject* args) { | |||||||
| return result; | ||||||||
| } | ||||||||
|
|
||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| static void | ||||||||
| _set_document_too_large(int size, long max) { | ||||||||
| PyObject* DocumentTooLarge = _error("DocumentTooLarge"); | ||||||||
|
|
@@ -352,7 +351,6 @@ _set_document_too_large(int size, long max) { | |||||||
| #define _DELETE 2 | ||||||||
|
|
||||||||
| /* OP_MSG ----------------------------------------------- */ | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| static int | ||||||||
| _batched_op_msg( | ||||||||
| unsigned char op, unsigned char ack, | ||||||||
|
|
@@ -658,7 +656,6 @@ _cbson_batched_op_msg(PyObject* self, PyObject* args) { | |||||||
| } | ||||||||
|
|
||||||||
| /* End OP_MSG -------------------------------------------- */ | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| static int | ||||||||
| _batched_write_command( | ||||||||
| char* ns, Py_ssize_t ns_len, unsigned char op, | ||||||||
|
|
@@ -862,7 +859,6 @@ _batched_write_command( | |||||||
| Py_XDECREF(iterator); | ||||||||
| return 0; | ||||||||
| } | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| static PyObject* | ||||||||
| _cbson_encode_batched_write_command(PyObject* self, PyObject* args) { | ||||||||
| char *ns = NULL; | ||||||||
|
|
@@ -1017,7 +1013,6 @@ _cmessage_exec(PyObject *m) | |||||||
| INITERROR; | ||||||||
| } | ||||||||
|
|
||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| static PyModuleDef_Slot _cmessage_slots[] = { | ||||||||
| {Py_mod_exec, _cmessage_exec}, | ||||||||
| #ifdef Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED | ||||||||
|
|
@@ -1029,7 +1024,6 @@ static PyModuleDef_Slot _cmessage_slots[] = { | |||||||
| {0, NULL}, | ||||||||
| }; | ||||||||
|
|
||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
|
||||||||
| static struct PyModuleDef moduledef = { | ||||||||
| PyModuleDef_HEAD_INIT, | ||||||||
| "_cmessage", | ||||||||
|
|
@@ -1046,4 +1040,3 @@ PyMODINIT_FUNC | |||||||
| PyInit__cmessage(void) | ||||||||
| { | ||||||||
| return PyModuleDef_Init(&moduledef); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| } | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.