Skip to content

Commit

Permalink
typecheck-gcc.h: check CURLINFO_CERTINFO
Browse files Browse the repository at this point in the history
... and update the certinfo.c example accordingly.

Fixes #846
  • Loading branch information
bagder committed Jun 1, 2017
1 parent 4eafc6c commit efc7c1d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
9 changes: 0 additions & 9 deletions docs/KNOWN_BUGS
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ problems may have been fixed or changed somewhat since this was written!
5.7 Visual Studio project gaps
5.8 configure finding libs in wrong directory
5.9 Utilize Requires.private directives in libcurl.pc
5.10 Fix the gcc typechecks

6. Authentication
6.1 NTLM authentication and unicode
Expand Down Expand Up @@ -364,14 +363,6 @@ problems may have been fixed or changed somewhat since this was written!

https://github.com/curl/curl/issues/864

5.10 Fix the gcc typechecks

Issue #846 identifies a problem with the gcc-typechecks and how the types are
documented and checked for CURLINFO_CERTINFO but our attempts to fix the
issue were futile and needs more attention.

https://github.com/curl/curl/issues/846

6. Authentication

6.1 NTLM authentication and unicode
Expand Down
19 changes: 7 additions & 12 deletions docs/examples/certinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
Expand Down Expand Up @@ -56,24 +56,19 @@ int main(void)
res = curl_easy_perform(curl);

if(!res) {
union {
struct curl_slist *to_info;
struct curl_certinfo *to_certinfo;
} ptr;
struct curl_certinfo *certinfo;

ptr.to_info = NULL;
res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &certinfo);

res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ptr.to_info);

if(!res && ptr.to_info) {
if(!res && certinfo) {
int i;

printf("%d certs!\n", ptr.to_certinfo->num_of_certs);
printf("%d certs!\n", certinfo->num_of_certs);

for(i = 0; i < ptr.to_certinfo->num_of_certs; i++) {
for(i = 0; i < certinfo->num_of_certs; i++) {
struct curl_slist *slist;

for(slist = ptr.to_certinfo->certinfo[i]; slist; slist = slist->next)
for(slist = certinfo->certinfo[i]; slist; slist = slist->next)
printf("%s\n", slist->data);

}
Expand Down
9 changes: 9 additions & 0 deletions include/curl/typecheck-gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ __extension__ ({ \
if(_curl_is_tlssessioninfo_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_tlssessioninfo *)) \
_curl_easy_getinfo_err_curl_tlssesssioninfo(); \
if(_curl_is_certinfo_info(_curl_info)) \
if(!_curl_is_arr((arg), struct curl_certinfo *)) \
_curl_easy_getinfo_err_curl_certinfo(); \
if(_curl_is_socket_info(_curl_info)) \
if(!_curl_is_arr((arg), curl_socket_t)) \
_curl_easy_getinfo_err_curl_socket(); \
Expand Down Expand Up @@ -210,6 +213,9 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_slist,
_CURL_WARNING(_curl_easy_getinfo_err_curl_tlssesssioninfo,
"curl_easy_getinfo expects a pointer to "
"'struct curl_tlssessioninfo *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_certinfo,
"curl_easy_getinfo expects a pointer to "
"'struct curl_certinfo *' for this info")
_CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
"curl_easy_getinfo expects a pointer to curl_socket_t for this info")

Expand Down Expand Up @@ -380,6 +386,9 @@ _CURL_WARNING(_curl_easy_getinfo_err_curl_socket,
#define _curl_is_tlssessioninfo_info(info) \
(((info) == CURLINFO_TLS_SSL_PTR) || ((info) == CURLINFO_TLS_SESSION))

/* true if info expects a pointer to struct curl_certinfo * argument */
#define _curl_is_certinfo_info(info) ((info) == CURLINFO_CERTINFO)

/* true if info expects a pointer to struct curl_socket_t argument */
#define _curl_is_socket_info(info) \
(CURLINFO_SOCKET < (info))
Expand Down

0 comments on commit efc7c1d

Please sign in to comment.