shithub: riscv

Download patch

ref: c4fec93ab9d544a72b189a602103ebed48a9829e
parent: ec37e34f0735d04ec912fab2d0b95aa40c72f527
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Feb 25 13:51:03 EST 2014

python: add buffer length check in sock_recvfrom_into()

--- a/sys/src/cmd/python/Modules/socketmodule.c
+++ b/sys/src/cmd/python/Modules/socketmodule.c
@@ -2547,6 +2547,12 @@
             recvlen = buflen;
 	}
 
+	if (buflen < recvlen) {
+		PyErr_SetString(PyExc_ValueError,
+				"buffer too small for requested bytes");
+		return NULL;
+	}
+
 	readlen = sock_recvfrom_guts(s, buf, recvlen, flags, &addr);
 	if (readlen < 0) {
 		/* Return an error */