urldata: make magic be the first struct field

By making the `magic` identifier the same size and at the same place
within the structs (easy, multi, share), libcurl will be able to more
reliably detect and safely error out if an application passes in the
wrong handle to APIs. Easier to detect and less likely to cause crashes
if done.

Such mixups can't be detected at compile-time due to them being
typedefed void pointers - unless `CURL_STRICTER` is defined.

Closes #6484
This commit is contained in:
Daniel Stenberg 2021-01-19 08:23:52 +01:00
parent 13bc1ea9bc
commit 942cf12c2f
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 24 additions and 11 deletions

View file

@ -2169,8 +2169,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->share = NULL;
}
/* use new share if it set */
data->share = set;
if(GOOD_SHARE_HANDLE(set))
/* use new share if it set */
data->share = set;
if(data->share) {
Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);