Issue #26644: Raise ValueError for negative SSLSocket.recv() and read()
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 8f34f95..23d4d5c 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -1695,6 +1695,10 @@
         goto error;
 
     if ((buf.buf == NULL) && (buf.obj == NULL)) {
+        if (len < 0) {
+            PyErr_SetString(PyExc_ValueError, "size should not be negative");
+            goto error;
+        }
         dest = PyBytes_FromStringAndSize(NULL, len);
         if (dest == NULL)
             goto error;