cURL / Mailing Lists / curl-library / Single Mail

curl-library

Problem using FTPS through HTTP Proxy (crash in cURL library)

From: Rocha, Marcos <marcos.rocha_at_siemens.com>
Date: Tue, 12 Sep 2006 17:44:21 +0200

Hi,

I'm using the cURL library for implementing a FTPS client that connects
to a FTPS server based on the QuickServer Java Library
(http://www.quickserver.org/). Everything works fine, if I directly
connect to the server. However, if I connect to the server through a
HTTP-Proxy and encryption is enabled (FTPS), I get a segmentation fault
on the cURL client (uninitialized pointer). For the client-server
communication I'm using FTPS with implicit SSL protection - that means
that both the control and the data channel are encrypted.

By enabling cURL's debugging option and by instrumenting the source code
I was able to find out the reason for the crash. Everything works fine
for the control connection. The segmentation fault occurs, when the cURL
library tries to establish the data connection through the HTTP-Proxy.
cURL erroneously assumes that the Connection-Request to the HTTP-Proxy
(for setting-up the data channel) is SSL encrypted. Then it calls
SSL_write passing a non-initialized ssl-handle, which leads to a crash
in the libssl.

I have a fix for this misbehavior. However, I'm not sure if this is the
most elegant fix... Maybe someone has another idea, how this should be
fixed?

My fix simply introduces a check for the initialization of the SSL
handle. If the handle has not been initialized, data is simply
read/written from/to the socket without any encryption. After the SSL
connection through the proxy is established the data gets encrypted as
usual.

Changes in file lib/sendf.c:
----------------------------
* in method Curl_write()
substitute:
  if (conn->ssl[num].use) {
by:
  if (conn->ssl[num].use && conn->ssl[num].handle != 0) {

* in method Curl_read()
substitute:
  if (conn->ssl[num].use) {
by:
  if (conn->ssl[num].use && conn->ssl[num].handle != 0) {
------------------------

Thanks for your help!

Marcos Rocha
Received on 2006-09-12