History

python: add buffer length check in sock_recvfrom_into()

cinap_lenrek committed 12 years ago

Commit abf07091 parent 091ae6b1 file · +6 −0Browse files

Showing the changes to sys/src/cmd/python/Modules/socketmodule.c (1 of 1 file). Show all

Unified · Split

sys/src/cmd/python/Modules/socketmodule.c+6−0
@@ -2547,6 +2547,12 @@ sock_recvfrom_into(PySocketSockObject *s, PyObject *args, PyObject* kwds) · 2546 unmodified lines
25472547 recvlen = buflen;
25482548 }
25492549
2550+ if (buflen < recvlen) {
2551+ PyErr_SetString(PyExc_ValueError,
2552+ "buffer too small for requested bytes");
2553+ return NULL;
2554+ }
2555+
25502556 readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr);
25512557 if (readlen < 0) {
25522558 /* Return an error */