diff options
author | Rob Austein <sra@hactrn.net> | 2009-07-18 03:43:48 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2009-07-18 03:43:48 +0000 |
commit | 28f6ce584802ad4fbba9096b9d1a289cbc52972d (patch) | |
tree | 7cc58591db9131e22f050db41f905bcb3cb1d1da /pow | |
parent | ee8f240881fb7a350edad5e0e9e27bee69b7c3e7 (diff) |
Attempting to read() from an uninitialized SSL object isn't useful,
but it shouldn't dump core either.
svn path=/pow/POW-0.7/POW.c; revision=2641
Diffstat (limited to 'pow')
-rw-r--r-- | pow/POW-0.7/POW.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/pow/POW-0.7/POW.c b/pow/POW-0.7/POW.c index d5ed05e6..3468b0d3 100644 --- a/pow/POW-0.7/POW.c +++ b/pow/POW-0.7/POW.c @@ -4141,8 +4141,8 @@ ssl_object_fileno(ssl_object *self, PyObject *args) if (!PyArg_ParseTuple(args, "")) goto error; - if (!self->ctxset || !self->ssl) - lose("File descriptor not set"); + if (!self->ctxset) + lose("cannot be called before setFd()"); return Py_BuildValue("i", SSL_get_fd(self->ssl)); @@ -4211,6 +4211,9 @@ ssl_object_accept(ssl_object *self, PyObject *args) if (!PyArg_ParseTuple(args, "")) goto error; + if (!self->ctxset) + lose("cannot be called before setFd()"); + Py_BEGIN_ALLOW_THREADS; ret = SSL_accept(self->ssl); Py_END_ALLOW_THREADS; @@ -4266,6 +4269,9 @@ ssl_object_connect(ssl_object *self, PyObject *args) if (!PyArg_ParseTuple(args, "")) goto error; + if (!self->ctxset) + lose("cannot be called before setFd()"); + Py_BEGIN_ALLOW_THREADS; ret = SSL_connect(self->ssl); Py_END_ALLOW_THREADS; @@ -4307,6 +4313,9 @@ ssl_object_write(ssl_object *self, PyObject *args) if (!PyArg_ParseTuple(args, "s#", &msg, &length)) goto error; + if (!self->ctxset) + lose("cannot be called before setFd()"); + Py_BEGIN_ALLOW_THREADS; ret = SSL_write(self->ssl, msg, length); Py_END_ALLOW_THREADS; @@ -4349,6 +4358,9 @@ ssl_object_read(ssl_object *self, PyObject *args) if (!PyArg_ParseTuple(args, "|i", &len)) goto error; + if (!self->ctxset) + lose("cannot be called before setFd()"); + if ((msg = malloc(len)) == NULL) lose("unable to allocate memory"); @@ -4397,6 +4409,9 @@ ssl_object_peer_certificate(ssl_object *self, PyObject *args) if (!PyArg_ParseTuple(args, "")) goto error; + if (!self->ctxset) + lose("cannot be called before setFd()"); + if ((x509_obj = X509_object_new()) == NULL) lose("could not create x509 object"); @@ -4442,6 +4457,9 @@ ssl_object_clear(ssl_object *self, PyObject *args) if (!PyArg_ParseTuple(args, "")) goto error; + if (!self->ctxset) + lose("cannot be called before setFd()"); + if (!SSL_clear(self->ssl)) lose("failed to clear ssl connection"); @@ -4488,6 +4506,9 @@ ssl_object_shutdown(ssl_object *self, PyObject *args) if (!PyArg_ParseTuple(args, "")) goto error; + if (!self->ctxset) + lose("cannot be called before setFd()"); + ret = SSL_shutdown(self->ssl); /* @@ -4546,6 +4567,9 @@ ssl_object_get_shutdown(ssl_object *self, PyObject *args) if (!PyArg_ParseTuple(args, "")) goto error; + if (!self->ctxset) + lose("cannot be called before setFd()"); + state = SSL_get_shutdown(self->ssl); return Py_BuildValue("i", state); |