From bd5edfdcadfe65e38539e8cb4b710848d97e3b3c Mon Sep 17 00:00:00 2001 From: "Christopher T. Johnson" Date: Tue, 23 Sep 2025 15:20:49 -0400 Subject: [PATCH] Only set one of HTTPGET, UPLOAD, POST or NOBODY curl options Fixes: #259 While s3.c: perform_request() is called with verb="PUT" libcurl sends a GET request. Since the method of the call is part of the S3 authorization hashing, the hashes do not match causing a Signature Error. libcurl's documentation says that a PUT will be done if the CURLOPT_UPLOAD, CURLOPT_READFUNCTION, and CURLOPT_READDATA are all set. What the documentation does not say is that only one of CURLOPT_HTTPGET, CURLOPT_UPLOAD, CURLOPT_POST, or CURLOPT_NOBODY can be set. In our case, we set CURLOPT_UPLOAD correctly and then set POST and NOBODY (to zero). This appears to reset the options to "none" which defaults to "GET" causing the GET instead of PUT. Using C's shortcut feture on conditionals, we check if the option should be set before we set the option. --- device-src/s3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/device-src/s3.c b/device-src/s3.c index 1b4cf10971..461f27ef4d 100644 --- a/device-src/s3.c +++ b/device-src/s3.c @@ -2634,13 +2634,13 @@ perform_request(S3Handle *hdl, } #endif - if ((curl_code = curl_easy_setopt(hdl->curl, CURLOPT_HTTPGET, curlopt_httpget))) + if (curlopt_httpget && (curl_code = curl_easy_setopt(hdl->curl, CURLOPT_HTTPGET, curlopt_httpget))) goto curl_error; - if ((curl_code = curl_easy_setopt(hdl->curl, CURLOPT_UPLOAD, curlopt_upload))) + if (curlopt_upload && (curl_code = curl_easy_setopt(hdl->curl, CURLOPT_UPLOAD, curlopt_upload))) goto curl_error; - if ((curl_code = curl_easy_setopt(hdl->curl, CURLOPT_POST, curlopt_post))) + if (curlopt_post && (curl_code = curl_easy_setopt(hdl->curl, CURLOPT_POST, curlopt_post))) goto curl_error; - if ((curl_code = curl_easy_setopt(hdl->curl, CURLOPT_NOBODY, curlopt_nobody))) + if (curlopt_nobody && (curl_code = curl_easy_setopt(hdl->curl, CURLOPT_NOBODY, curlopt_nobody))) goto curl_error; if ((curl_code = curl_easy_setopt(hdl->curl, CURLOPT_CUSTOMREQUEST, curlopt_customrequest)))