Hello all,

I'm maintaining a Rust cli that uses libcurl for HTTP exchanges. I'm trying to 
understand why I see a libcurl log in my Rust sample

`* boolean setopt(81) got unsupported argument 2, treated as 1`

(81 => CURLOPT_SSL_VERIFYHOST) in some basic samples appearing with libcurl 
8.16.0 (I'm testing it on Archlinux)

I'm reaching this channel, because, in my investigation, I've found that there 
are some relatively recent changes in curl regarding `setopt_long`/ 
`setopt_bool` (see <https://github.com/curl/curl/pull/17887>). The cullprit is 
certainly in Rust wrapping code around C libcurl but I want to get some advices 
from libcurl expert.

The Rust code that trigges this warning is:

```
fn fetch_url(url: &str) {
    unsafe {
        curl_sys::curl_global_init(curl_sys::CURL_GLOBAL_ALL);

        let handle = curl_sys::curl_easy_init();

        let url = CString::new(url).unwrap();

        let ret = curl_sys::curl_easy_setopt(handle, curl_sys::CURLOPT_URL, 
url.as_ptr());
        ok_or_exit(ret);

        let ret = curl_sys::curl_easy_setopt(handle, curl_sys::CURLOPT_VERBOSE, 
1);
        ok_or_exit(ret);

        let ret = curl_sys::curl_easy_setopt(handle, 
curl_sys::CURLOPT_SSL_VERIFYHOST, 2);
        ok_or_exit(ret);

        let ret = curl_sys::curl_easy_perform(handle);
        ok_or_exit(ret);
    }
}
```

The Rust function `curl_sys::curl_easy_setopt` is defined as (still Rust code 
sorry!):

```
extern "C" {
        ...
        pub fn curl_easy_setopt(curl: *mut CURL, option: CURLoption, ...) -> 
CURLcode;
```


This seems to me (certainly wrongly) a direct call to the C libcurl function 
`CURL_EXTERN CURLcode curl_easy_setopt(CURL *curl, CURLoption option, ...)`

So, when the Rust call is

```
let ret = curl_sys::curl_easy_setopt(handle, curl_sys::CURLOPT_SSL_VERIFYHOST, 
2);
```

It should call the corresponding libcurl function `CURLcode curl_easy_setopt`, 
then `Curl_vsetopt` and finally `setopt_long`.

All this code seems OK to me, I don't see any "weird" logic in Rust warpping 
around libcurl and yet, at runtime, with libcurl 8.16.0 I see this log:

`* boolean setopt(81) got unsupported argument 2, treated as 1` in some basic 
sample with libcurl 8.16.0.`

As if the path code call triggers a `setopt_bool`.

I'm sorry to ask for advices for this problem (for a Rust cli and certainlty 
not a libcurl issue) but I'm a litle stuck in trying to understand this issue.

Thanks for any thought!

Jicea






Orange Restricted
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations 
confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce 
message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages 
electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou 
falsifie. Merci.

This message and its attachments may contain confidential or privileged 
information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete 
this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been 
modified, changed or falsified.
Thank you.
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to