diff options
author | Daniel Stenberg <daniel@haxx.se> | 2007-11-12 21:38:43 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2007-11-12 21:38:43 +0000 |
commit | c5b16d44680cdb81aab2c3af0f5b3ec220aafc39 (patch) | |
tree | c93c2b0e62b425447a7fcda1285a613361286519 /lib | |
parent | 3c71a1bab77be5e687699fa2735a8673ee96d62d (diff) |
Bug report #1830637 (http://curl.haxx.se/bug/view.cgi?id=1830637), which was
forwarded from the Gentoo bug tracker by Daniel Black and was originally
submitted by Robin Johnson, pointed out that libcurl would do bad memory
references when it failed and bailed out before the handler thing was
setup. My fix is not done like the provided patch does it, but instead I
make sure that there's never any chance for a NULL pointer in that struct
member.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/url.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -2134,7 +2134,7 @@ CURLcode Curl_disconnect(struct connectdata *conn) Curl_ntlm_cleanup(conn); } - if(conn->handler && conn->handler->disconnect) + if(conn->handler->disconnect) /* This is set if protocol-specific cleanups should be made */ conn->handler->disconnect(conn); @@ -2668,7 +2668,7 @@ int Curl_doing_getsock(struct connectdata *conn, curl_socket_t *socks, int numsocks) { - if(conn && conn->handler && conn->handler->doing_getsock) + if(conn && conn->handler->doing_getsock) return conn->handler->doing_getsock(conn, socks, numsocks); return GETSOCK_BLANK; } @@ -2684,7 +2684,7 @@ CURLcode Curl_protocol_connecting(struct connectdata *conn, { CURLcode result=CURLE_OK; - if(conn && conn->handler && conn->handler->connecting) { + if(conn && conn->handler->connecting) { *done = FALSE; result = conn->handler->connecting(conn, done); } @@ -2703,7 +2703,7 @@ CURLcode Curl_protocol_doing(struct connectdata *conn, bool *done) { CURLcode result=CURLE_OK; - if(conn && conn->handler && conn->handler->doing) { + if(conn && conn->handler->doing) { *done = FALSE; result = conn->handler->doing(conn, done); } @@ -3111,8 +3111,9 @@ static CURLcode setup_connection_internals(struct SessionHandle *data, return CURLE_OK; } - /* Protocol not found in table. */ - conn->handler = &Curl_handler_dummy; /* Be sure we have a handler defined. */ + /* Protocol not found in table, but we don't have to assign it to anything + since it is already assign to a dummy-struct in the CreateConnection() + struct when the connectdata struct is allocated. */ failf(data, "Protocol %s not supported or disabled in " LIBCURL_NAME, conn->protostr); return CURLE_UNSUPPORTED_PROTOCOL; @@ -3470,6 +3471,10 @@ static CURLcode CreateConnection(struct SessionHandle *data, any failure */ *in_connect = conn; + conn->handler = &Curl_handler_dummy; /* Be sure we have a handler defined + already from start to avoid NULL + situations and checks */ + /* and we setup a few fields in case we end up actually using this struct */ conn->data = data; /* Setup the association between this connection |