summaryrefslogtreecommitdiff
path: root/lib/urldata.h
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-01-19 08:23:52 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-01-20 08:51:01 +0100
commit942cf12c2f73c4bb13858acc9101b1d644bf7c50 (patch)
tree0478f4aa93712d7b06b39da268aaae9ec102f312 /lib/urldata.h
parent13bc1ea9bcef34c4beb384549e4be64e341426db (diff)
downloadcurl-942cf12c2f73c4bb13858acc9101b1d644bf7c50.tar.gz
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
Diffstat (limited to 'lib/urldata.h')
-rw-r--r--lib/urldata.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/urldata.h b/lib/urldata.h
index 072caf002..1aa585077 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -1884,6 +1884,10 @@ struct Names {
*/
struct Curl_easy {
+ /* First a simple identifier to easier detect if a user mix up this easy
+ handle with a multi handle. Set this to CURLEASY_MAGIC_NUMBER */
+ unsigned int magic;
+
/* first, two fields for the linked list of these */
struct Curl_easy *next;
struct Curl_easy *prev;
@@ -1947,7 +1951,6 @@ struct Curl_easy {
#ifdef USE_HYPER
struct hyptransfer hyp;
#endif
- unsigned int magic; /* set to a CURLEASY_MAGIC_NUMBER */
};
#define LIBCURL_NAME "libcurl"