# [PATCH] Do curl option disabling before enabling new options

3 messages from 2009-04-14 to 2009-11-23. Participants: Martin Storsjö, Tay Ray Chuan.
Thread: https://gitlist.dev/t/18869

## Martin Storsjö, 2009-04-14 19:01

Subject: [PATCH] Do curl option disabling before enabling new options
Message-ID: <Pine.LNX.4.64.0904142200130.7479@localhost.localdomain>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0904142200130.7479%40localhost.localdomain

```
This works around a bug in curl versions up to 7.19.4, where
disabling the CURLOPT_NOBODY option sets the internal state
incorrectly considering that CURLOPT_PUT was enabled earlier.

The bug is discussed at http://curl.haxx.se/bug/view.cgi?id=2727981
and is corrected in the latest version of curl in CVS.

This bug usually has no impact on git, but may surface if using
multi-pass authentication methods.

Signed-off-by: Martin Storsjo <martin@martin.st>
---
 http-push.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/http-push.c b/http-push.c
index 5138224..3629492 100644
--- a/http-push.c
+++ b/http-push.c
@@ -599,9 +599,9 @@ static void start_put(struct transfer_request *request)
 #endif
 	curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
 	curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PUT);
+	curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
 	curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);
 	curl_easy_setopt(slot->curl, CURLOPT_PUT, 1);
-	curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
 	curl_easy_setopt(slot->curl, CURLOPT_URL, request->url);
 
 	if (start_active_slot(slot)) {
-- 
1.6.0.2

```

## Tay Ray Chuan, 2009-11-23 03:03

Subject: [PATCH 1/2] Do curl option disabling before enabling new options
Message-ID: <20091123110328.748fcf09.rctay89@gmail.com>
URL: https://gitlist.dev/e/20091123110328.748fcf09.rctay89%40gmail.com
In-Reply-To: <Pine.LNX.4.64.0904142200130.7479@localhost.localdomain>

```
From: =?ISO-8859-15?Q?Martin_Storsj=F6?= <martin@martin.st>

This works around a bug in curl versions up to 7.19.4, where
disabling the CURLOPT_NOBODY option sets the internal state
incorrectly considering that CURLOPT_PUT was enabled earlier.

The bug is discussed at http://curl.haxx.se/bug/view.cgi?id=2727981
and is corrected in the latest version of curl in CVS.

This bug usually has no impact on git, but may surface if using
multi-pass authentication methods.

Signed-off-by: Martin Storsjo <martin@martin.st>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---

  Squashed in another potential trigger for this bug in remote-curl.c,
  introduced in 'next'.

 http-push.c   |    2 +-
 remote-curl.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/http-push.c b/http-push.c
index f10803a..295f1fb 100644
--- a/http-push.c
+++ b/http-push.c
@@ -408,10 +408,10 @@ static void start_put(struct transfer_request *request)
 	curl_easy_setopt(slot->curl, CURLOPT_IOCTLDATA, &request->buffer);
 #endif
 	curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_null);
+	curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
 	curl_easy_setopt(slot->curl, CURLOPT_CUSTOMREQUEST, DAV_PUT);
 	curl_easy_setopt(slot->curl, CURLOPT_UPLOAD, 1);
 	curl_easy_setopt(slot->curl, CURLOPT_PUT, 1);
-	curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
 	curl_easy_setopt(slot->curl, CURLOPT_URL, request->url);

 	if (start_active_slot(slot)) {
diff --git a/remote-curl.c b/remote-curl.c
index 4f28c22..69eaf58 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -356,8 +356,8 @@ static int post_rpc(struct rpc_state *rpc)
 	slot = get_active_slot();
 	slot->results = &results;

-	curl_easy_setopt(slot->curl, CURLOPT_POST, 1);
 	curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
+	curl_easy_setopt(slot->curl, CURLOPT_POST, 1);
 	curl_easy_setopt(slot->curl, CURLOPT_URL, rpc->service_url);
 	curl_easy_setopt(slot->curl, CURLOPT_ENCODING, "");

--
1.6.4.4

```

## Tay Ray Chuan, 2009-11-23 03:05

Subject: Re: [PATCH 1/2] Do curl option disabling before enabling new options
Message-ID: <be6fef0d0911221905o2e4eae93l1915c16dacfce7a9@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0911221905o2e4eae93l1915c16dacfce7a9%40mail.gmail.com
In-Reply-To: <20091123110328.748fcf09.rctay89@gmail.com>

```
Hi,

On Mon, Nov 23, 2009 at 11:03 AM, Tay Ray Chuan <rctay89@gmail.com> wrote:
>  Squashed in another potential trigger for this bug in remote-curl.c,
>  introduced in 'next'.

sorry, this should now read 'master'.

-- 
Cheers,
Ray Chuan

```
