mirror of
https://github.com/curl/curl.git
synced 2026-08-25 12:23:44 +03:00
source cleanup: remove all custom typedef structs
- Stick to a single unified way to use structs
- Make checksrc complain on 'typedef struct {'
- Allow them in tests, public headers and examples
- Let MD4_CTX, MD5_CTX, and SHA256_CTX typedefs remain as they actually
typedef different types/structs depending on build conditions.
Closes #5338
This commit is contained in:
parent
5d54b5e697
commit
8df455479f
71 changed files with 718 additions and 672 deletions
|
|
@ -87,7 +87,8 @@
|
|||
|
||||
struct ResolverResults {
|
||||
int num_pending; /* number of ares_gethostbyname() requests */
|
||||
Curl_addrinfo *temp_ai; /* intermediary result while fetching c-ares parts */
|
||||
struct Curl_addrinfo *temp_ai; /* intermediary result while fetching c-ares
|
||||
parts */
|
||||
int last_status;
|
||||
struct curltime happy_eyeballs_dns_time; /* when this timer started, or 0 */
|
||||
};
|
||||
|
|
@ -494,9 +495,9 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
|
|||
|
||||
/* Connects results to the list */
|
||||
static void compound_results(struct ResolverResults *res,
|
||||
Curl_addrinfo *ai)
|
||||
struct Curl_addrinfo *ai)
|
||||
{
|
||||
Curl_addrinfo *ai_tail;
|
||||
struct Curl_addrinfo *ai_tail;
|
||||
if(!ai)
|
||||
return;
|
||||
ai_tail = ai;
|
||||
|
|
@ -538,7 +539,7 @@ static void query_completed_cb(void *arg, /* (struct connectdata *) */
|
|||
res->num_pending--;
|
||||
|
||||
if(CURL_ASYNC_SUCCESS == status) {
|
||||
Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port);
|
||||
struct Curl_addrinfo *ai = Curl_he2ai(hostent, conn->async.port);
|
||||
if(ai) {
|
||||
compound_results(res, ai);
|
||||
}
|
||||
|
|
@ -617,10 +618,10 @@ static void query_completed_cb(void *arg, /* (struct connectdata *) */
|
|||
* memory we need to free after use. That memory *MUST* be freed with
|
||||
* Curl_freeaddrinfo(), nothing else.
|
||||
*/
|
||||
Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
{
|
||||
char *bufp;
|
||||
struct Curl_easy *data = conn->data;
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ struct thread_sync_data {
|
|||
curl_socket_t sock_pair[2]; /* socket pair */
|
||||
#endif
|
||||
int sock_error;
|
||||
Curl_addrinfo *res;
|
||||
struct Curl_addrinfo *res;
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
struct addrinfo hints;
|
||||
#endif
|
||||
|
|
@ -690,10 +690,10 @@ int Curl_resolver_getsock(struct connectdata *conn,
|
|||
/*
|
||||
* Curl_getaddrinfo() - for platforms without getaddrinfo
|
||||
*/
|
||||
Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
{
|
||||
struct Curl_easy *data = conn->data;
|
||||
struct resdata *reslv = (struct resdata *)data->state.resolver;
|
||||
|
|
@ -718,10 +718,10 @@ Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
|
|||
/*
|
||||
* Curl_resolver_getaddrinfo() - for getaddrinfo
|
||||
*/
|
||||
Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
int pf = PF_INET;
|
||||
|
|
|
|||
10
lib/asyn.h
10
lib/asyn.h
|
|
@ -7,7 +7,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -153,10 +153,10 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
|
|||
* Each resolver backend must of course make sure to return data in the
|
||||
* correct format to comply with this.
|
||||
*/
|
||||
Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp);
|
||||
struct Curl_addrinfo *Curl_resolver_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp);
|
||||
|
||||
#ifndef CURLRES_ASYNCH
|
||||
/* convert these functions if an asynch resolver isn't used */
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ my %warnings = (
|
|||
'SIZEOFNOPAREN' => 'use of sizeof without parentheses',
|
||||
'SNPRINTF' => 'use of snprintf',
|
||||
'ONELINECONDITION' => 'conditional block on the same line as the if()',
|
||||
'TYPEDEFSTRUCT' => 'typedefed struct',
|
||||
);
|
||||
|
||||
sub readwhitelist {
|
||||
|
|
@ -116,6 +117,14 @@ sub readlocalfile {
|
|||
}
|
||||
$warnings{$1} = $warnings_extended{$1};
|
||||
}
|
||||
elsif (/^\s*disable ([A-Z]+)$/) {
|
||||
if(!defined($warnings{$1})) {
|
||||
print STDERR "invalid warning specified in .checksrc: \"$1\"\n";
|
||||
next;
|
||||
}
|
||||
# Accept-list
|
||||
push @alist, $1;
|
||||
}
|
||||
else {
|
||||
die "Invalid format in $dir/.checksrc on line $i\n";
|
||||
}
|
||||
|
|
@ -698,6 +707,13 @@ sub scanfile {
|
|||
"no space after semicolon");
|
||||
}
|
||||
|
||||
# typedef struct ... {
|
||||
if($nostr =~ /^(.*)typedef struct.*{/) {
|
||||
checkwarn("TYPEDEFSTRUCT",
|
||||
$line, length($1)+1, $file, $ol,
|
||||
"typedef'ed struct");
|
||||
}
|
||||
|
||||
# check for more than one consecutive space before open brace or
|
||||
# question mark. Skip lines containing strings since they make it hard
|
||||
# due to artificially getting multiple spaces
|
||||
|
|
|
|||
|
|
@ -724,6 +724,7 @@ Vista
|
|||
/* Replicating logic present in afunix.h of newer Windows 10 SDK versions */
|
||||
# define UNIX_PATH_MAX 108
|
||||
# include <ws2tcpip.h>
|
||||
/* !checksrc! disable TYPEDEFSTRUCT 1 */
|
||||
typedef struct sockaddr_un {
|
||||
ADDRESS_FAMILY sun_family;
|
||||
char sun_path[UNIX_PATH_MAX];
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ tcpkeepalive(struct Curl_easy *data,
|
|||
|
||||
static CURLcode
|
||||
singleipconnect(struct connectdata *conn,
|
||||
const Curl_addrinfo *ai, /* start connecting to this */
|
||||
const struct Curl_addrinfo *ai, /* start connecting to this */
|
||||
int tempindex); /* 0 or 1 among the temp ones */
|
||||
|
||||
/*
|
||||
|
|
@ -558,11 +558,11 @@ static bool verifyconnect(curl_socket_t sockfd, int *error)
|
|||
|
||||
/* update tempaddr[tempindex] (to the next entry), makes sure to stick
|
||||
to the correct family */
|
||||
static Curl_addrinfo *ainext(struct connectdata *conn,
|
||||
int tempindex,
|
||||
bool next) /* use current or next entry */
|
||||
static struct Curl_addrinfo *ainext(struct connectdata *conn,
|
||||
int tempindex,
|
||||
bool next) /* use current or next entry */
|
||||
{
|
||||
Curl_addrinfo *ai = conn->tempaddr[tempindex];
|
||||
struct Curl_addrinfo *ai = conn->tempaddr[tempindex];
|
||||
if(ai && next)
|
||||
ai = ai->ai_next;
|
||||
while(ai && (ai->ai_family != conn->tempfamily[tempindex]))
|
||||
|
|
@ -587,7 +587,7 @@ static CURLcode trynextip(struct connectdata *conn,
|
|||
conn->tempsock[tempindex] = CURL_SOCKET_BAD;
|
||||
|
||||
if(sockindex == FIRSTSOCKET) {
|
||||
Curl_addrinfo *ai = conn->tempaddr[tempindex];
|
||||
struct Curl_addrinfo *ai = conn->tempaddr[tempindex];
|
||||
|
||||
while(ai) {
|
||||
if(ai) {
|
||||
|
|
@ -1113,7 +1113,7 @@ void Curl_sndbufset(curl_socket_t sockfd)
|
|||
* having connected.
|
||||
*/
|
||||
static CURLcode singleipconnect(struct connectdata *conn,
|
||||
const Curl_addrinfo *ai,
|
||||
const struct Curl_addrinfo *ai,
|
||||
int tempindex)
|
||||
{
|
||||
struct Curl_sockaddr_ex addr;
|
||||
|
|
@ -1485,7 +1485,7 @@ int Curl_closesocket(struct connectdata *conn,
|
|||
*
|
||||
*/
|
||||
CURLcode Curl_socket(struct connectdata *conn,
|
||||
const Curl_addrinfo *ai,
|
||||
const struct Curl_addrinfo *ai,
|
||||
struct Curl_sockaddr_ex *addr,
|
||||
curl_socket_t *sockfd)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -105,7 +105,7 @@ struct Curl_sockaddr_ex {
|
|||
*
|
||||
*/
|
||||
CURLcode Curl_socket(struct connectdata *conn,
|
||||
const Curl_addrinfo *ai,
|
||||
const struct Curl_addrinfo *ai,
|
||||
struct Curl_sockaddr_ex *addr,
|
||||
curl_socket_t *sockfd);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -81,11 +81,11 @@ typedef enum {
|
|||
} zlibInitState;
|
||||
|
||||
/* Writer parameters. */
|
||||
typedef struct {
|
||||
struct zlib_params {
|
||||
zlibInitState zlib_init; /* zlib init state */
|
||||
uInt trailerlen; /* Remaining trailer byte count. */
|
||||
z_stream z; /* State structure for zlib. */
|
||||
} zlib_params;
|
||||
};
|
||||
|
||||
|
||||
static voidpf
|
||||
|
|
@ -133,7 +133,8 @@ exit_zlib(struct connectdata *conn,
|
|||
return result;
|
||||
}
|
||||
|
||||
static CURLcode process_trailer(struct connectdata *conn, zlib_params *zp)
|
||||
static CURLcode process_trailer(struct connectdata *conn,
|
||||
struct zlib_params *zp)
|
||||
{
|
||||
z_stream *z = &zp->z;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
|
@ -157,9 +158,10 @@ static CURLcode process_trailer(struct connectdata *conn, zlib_params *zp)
|
|||
}
|
||||
|
||||
static CURLcode inflate_stream(struct connectdata *conn,
|
||||
contenc_writer *writer, zlibInitState started)
|
||||
struct contenc_writer *writer,
|
||||
zlibInitState started)
|
||||
{
|
||||
zlib_params *zp = (zlib_params *) &writer->params;
|
||||
struct zlib_params *zp = (struct zlib_params *) &writer->params;
|
||||
z_stream *z = &zp->z; /* zlib state structure */
|
||||
uInt nread = z->avail_in;
|
||||
Bytef *orig_in = z->next_in;
|
||||
|
|
@ -259,9 +261,9 @@ static CURLcode inflate_stream(struct connectdata *conn,
|
|||
|
||||
/* Deflate handler. */
|
||||
static CURLcode deflate_init_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
zlib_params *zp = (zlib_params *) &writer->params;
|
||||
struct zlib_params *zp = (struct zlib_params *) &writer->params;
|
||||
z_stream *z = &zp->z; /* zlib state structure */
|
||||
|
||||
if(!writer->downstream)
|
||||
|
|
@ -278,10 +280,10 @@ static CURLcode deflate_init_writer(struct connectdata *conn,
|
|||
}
|
||||
|
||||
static CURLcode deflate_unencode_write(struct connectdata *conn,
|
||||
contenc_writer *writer,
|
||||
struct contenc_writer *writer,
|
||||
const char *buf, size_t nbytes)
|
||||
{
|
||||
zlib_params *zp = (zlib_params *) &writer->params;
|
||||
struct zlib_params *zp = (struct zlib_params *) &writer->params;
|
||||
z_stream *z = &zp->z; /* zlib state structure */
|
||||
|
||||
/* Set the compressed input when this function is called */
|
||||
|
|
@ -296,29 +298,29 @@ static CURLcode deflate_unencode_write(struct connectdata *conn,
|
|||
}
|
||||
|
||||
static void deflate_close_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
zlib_params *zp = (zlib_params *) &writer->params;
|
||||
struct zlib_params *zp = (struct zlib_params *) &writer->params;
|
||||
z_stream *z = &zp->z; /* zlib state structure */
|
||||
|
||||
exit_zlib(conn, z, &zp->zlib_init, CURLE_OK);
|
||||
}
|
||||
|
||||
static const content_encoding deflate_encoding = {
|
||||
static const struct content_encoding deflate_encoding = {
|
||||
"deflate",
|
||||
NULL,
|
||||
deflate_init_writer,
|
||||
deflate_unencode_write,
|
||||
deflate_close_writer,
|
||||
sizeof(zlib_params)
|
||||
sizeof(struct zlib_params)
|
||||
};
|
||||
|
||||
|
||||
/* Gzip handler. */
|
||||
static CURLcode gzip_init_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
zlib_params *zp = (zlib_params *) &writer->params;
|
||||
struct zlib_params *zp = (struct zlib_params *) &writer->params;
|
||||
z_stream *z = &zp->z; /* zlib state structure */
|
||||
|
||||
if(!writer->downstream)
|
||||
|
|
@ -432,10 +434,10 @@ static enum {
|
|||
#endif
|
||||
|
||||
static CURLcode gzip_unencode_write(struct connectdata *conn,
|
||||
contenc_writer *writer,
|
||||
struct contenc_writer *writer,
|
||||
const char *buf, size_t nbytes)
|
||||
{
|
||||
zlib_params *zp = (zlib_params *) &writer->params;
|
||||
struct zlib_params *zp = (struct zlib_params *) &writer->params;
|
||||
z_stream *z = &zp->z; /* zlib state structure */
|
||||
|
||||
if(zp->zlib_init == ZLIB_INIT_GZIP) {
|
||||
|
|
@ -560,33 +562,31 @@ static CURLcode gzip_unencode_write(struct connectdata *conn,
|
|||
}
|
||||
|
||||
static void gzip_close_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
zlib_params *zp = (zlib_params *) &writer->params;
|
||||
struct zlib_params *zp = (struct zlib_params *) &writer->params;
|
||||
z_stream *z = &zp->z; /* zlib state structure */
|
||||
|
||||
exit_zlib(conn, z, &zp->zlib_init, CURLE_OK);
|
||||
}
|
||||
|
||||
static const content_encoding gzip_encoding = {
|
||||
static const struct content_encoding gzip_encoding = {
|
||||
"gzip",
|
||||
"x-gzip",
|
||||
gzip_init_writer,
|
||||
gzip_unencode_write,
|
||||
gzip_close_writer,
|
||||
sizeof(zlib_params)
|
||||
sizeof(struct zlib_params)
|
||||
};
|
||||
|
||||
#endif /* HAVE_LIBZ */
|
||||
|
||||
|
||||
#ifdef HAVE_BROTLI
|
||||
|
||||
/* Writer parameters. */
|
||||
typedef struct {
|
||||
struct brotli_params {
|
||||
BrotliDecoderState *br; /* State structure for brotli. */
|
||||
} brotli_params;
|
||||
|
||||
};
|
||||
|
||||
static CURLcode brotli_map_error(BrotliDecoderErrorCode be)
|
||||
{
|
||||
|
|
@ -627,10 +627,9 @@ static CURLcode brotli_map_error(BrotliDecoderErrorCode be)
|
|||
}
|
||||
|
||||
static CURLcode brotli_init_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
brotli_params *bp = (brotli_params *) &writer->params;
|
||||
|
||||
struct brotli_params *bp = (struct brotli_params *) &writer->params;
|
||||
(void) conn;
|
||||
|
||||
if(!writer->downstream)
|
||||
|
|
@ -641,10 +640,10 @@ static CURLcode brotli_init_writer(struct connectdata *conn,
|
|||
}
|
||||
|
||||
static CURLcode brotli_unencode_write(struct connectdata *conn,
|
||||
contenc_writer *writer,
|
||||
struct contenc_writer *writer,
|
||||
const char *buf, size_t nbytes)
|
||||
{
|
||||
brotli_params *bp = (brotli_params *) &writer->params;
|
||||
struct brotli_params *bp = (struct brotli_params *) &writer->params;
|
||||
const uint8_t *src = (const uint8_t *) buf;
|
||||
char *decomp;
|
||||
uint8_t *dst;
|
||||
|
|
@ -689,10 +688,9 @@ static CURLcode brotli_unencode_write(struct connectdata *conn,
|
|||
}
|
||||
|
||||
static void brotli_close_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
brotli_params *bp = (brotli_params *) &writer->params;
|
||||
|
||||
struct brotli_params *bp = (struct brotli_params *) &writer->params;
|
||||
(void) conn;
|
||||
|
||||
if(bp->br) {
|
||||
|
|
@ -701,40 +699,40 @@ static void brotli_close_writer(struct connectdata *conn,
|
|||
}
|
||||
}
|
||||
|
||||
static const content_encoding brotli_encoding = {
|
||||
static const struct content_encoding brotli_encoding = {
|
||||
"br",
|
||||
NULL,
|
||||
brotli_init_writer,
|
||||
brotli_unencode_write,
|
||||
brotli_close_writer,
|
||||
sizeof(brotli_params)
|
||||
sizeof(struct brotli_params)
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/* Identity handler. */
|
||||
static CURLcode identity_init_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
(void) conn;
|
||||
return writer->downstream? CURLE_OK: CURLE_WRITE_ERROR;
|
||||
}
|
||||
|
||||
static CURLcode identity_unencode_write(struct connectdata *conn,
|
||||
contenc_writer *writer,
|
||||
struct contenc_writer *writer,
|
||||
const char *buf, size_t nbytes)
|
||||
{
|
||||
return Curl_unencode_write(conn, writer->downstream, buf, nbytes);
|
||||
}
|
||||
|
||||
static void identity_close_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
(void) conn;
|
||||
(void) writer;
|
||||
}
|
||||
|
||||
static const content_encoding identity_encoding = {
|
||||
static const struct content_encoding identity_encoding = {
|
||||
"identity",
|
||||
"none",
|
||||
identity_init_writer,
|
||||
|
|
@ -745,7 +743,7 @@ static const content_encoding identity_encoding = {
|
|||
|
||||
|
||||
/* supported content encodings table. */
|
||||
static const content_encoding * const encodings[] = {
|
||||
static const struct content_encoding * const encodings[] = {
|
||||
&identity_encoding,
|
||||
#ifdef HAVE_LIBZ
|
||||
&deflate_encoding,
|
||||
|
|
@ -762,8 +760,8 @@ static const content_encoding * const encodings[] = {
|
|||
char *Curl_all_content_encodings(void)
|
||||
{
|
||||
size_t len = 0;
|
||||
const content_encoding * const *cep;
|
||||
const content_encoding *ce;
|
||||
const struct content_encoding * const *cep;
|
||||
const struct content_encoding *ce;
|
||||
char *ace;
|
||||
|
||||
for(cep = encodings; *cep; cep++) {
|
||||
|
|
@ -796,14 +794,14 @@ char *Curl_all_content_encodings(void)
|
|||
|
||||
/* Real client writer: no downstream. */
|
||||
static CURLcode client_init_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
(void) conn;
|
||||
return writer->downstream? CURLE_WRITE_ERROR: CURLE_OK;
|
||||
}
|
||||
|
||||
static CURLcode client_unencode_write(struct connectdata *conn,
|
||||
contenc_writer *writer,
|
||||
struct contenc_writer *writer,
|
||||
const char *buf, size_t nbytes)
|
||||
{
|
||||
struct Curl_easy *data = conn->data;
|
||||
|
|
@ -818,13 +816,13 @@ static CURLcode client_unencode_write(struct connectdata *conn,
|
|||
}
|
||||
|
||||
static void client_close_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
(void) conn;
|
||||
(void) writer;
|
||||
}
|
||||
|
||||
static const content_encoding client_encoding = {
|
||||
static const struct content_encoding client_encoding = {
|
||||
NULL,
|
||||
NULL,
|
||||
client_init_writer,
|
||||
|
|
@ -836,14 +834,14 @@ static const content_encoding client_encoding = {
|
|||
|
||||
/* Deferred error dummy writer. */
|
||||
static CURLcode error_init_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
(void) conn;
|
||||
return writer->downstream? CURLE_OK: CURLE_WRITE_ERROR;
|
||||
}
|
||||
|
||||
static CURLcode error_unencode_write(struct connectdata *conn,
|
||||
contenc_writer *writer,
|
||||
struct contenc_writer *writer,
|
||||
const char *buf, size_t nbytes)
|
||||
{
|
||||
char *all = Curl_all_content_encodings();
|
||||
|
|
@ -861,13 +859,13 @@ static CURLcode error_unencode_write(struct connectdata *conn,
|
|||
}
|
||||
|
||||
static void error_close_writer(struct connectdata *conn,
|
||||
contenc_writer *writer)
|
||||
struct contenc_writer *writer)
|
||||
{
|
||||
(void) conn;
|
||||
(void) writer;
|
||||
}
|
||||
|
||||
static const content_encoding error_encoding = {
|
||||
static const struct content_encoding error_encoding = {
|
||||
NULL,
|
||||
NULL,
|
||||
error_init_writer,
|
||||
|
|
@ -877,12 +875,13 @@ static const content_encoding error_encoding = {
|
|||
};
|
||||
|
||||
/* Create an unencoding writer stage using the given handler. */
|
||||
static contenc_writer *new_unencoding_writer(struct connectdata *conn,
|
||||
const content_encoding *handler,
|
||||
contenc_writer *downstream)
|
||||
static struct contenc_writer *
|
||||
new_unencoding_writer(struct connectdata *conn,
|
||||
const struct content_encoding *handler,
|
||||
struct contenc_writer *downstream)
|
||||
{
|
||||
size_t sz = offsetof(contenc_writer, params) + handler->paramsize;
|
||||
contenc_writer *writer = (contenc_writer *) calloc(1, sz);
|
||||
size_t sz = offsetof(struct contenc_writer, params) + handler->paramsize;
|
||||
struct contenc_writer *writer = (struct contenc_writer *)calloc(1, sz);
|
||||
|
||||
if(writer) {
|
||||
writer->handler = handler;
|
||||
|
|
@ -897,7 +896,8 @@ static contenc_writer *new_unencoding_writer(struct connectdata *conn,
|
|||
}
|
||||
|
||||
/* Write data using an unencoding writer stack. */
|
||||
CURLcode Curl_unencode_write(struct connectdata *conn, contenc_writer *writer,
|
||||
CURLcode Curl_unencode_write(struct connectdata *conn,
|
||||
struct contenc_writer *writer,
|
||||
const char *buf, size_t nbytes)
|
||||
{
|
||||
if(!nbytes)
|
||||
|
|
@ -910,7 +910,7 @@ void Curl_unencode_cleanup(struct connectdata *conn)
|
|||
{
|
||||
struct Curl_easy *data = conn->data;
|
||||
struct SingleRequest *k = &data->req;
|
||||
contenc_writer *writer = k->writer_stack;
|
||||
struct contenc_writer *writer = k->writer_stack;
|
||||
|
||||
while(writer) {
|
||||
k->writer_stack = writer->downstream;
|
||||
|
|
@ -921,12 +921,13 @@ void Curl_unencode_cleanup(struct connectdata *conn)
|
|||
}
|
||||
|
||||
/* Find the content encoding by name. */
|
||||
static const content_encoding *find_encoding(const char *name, size_t len)
|
||||
static const struct content_encoding *find_encoding(const char *name,
|
||||
size_t len)
|
||||
{
|
||||
const content_encoding * const *cep;
|
||||
const struct content_encoding * const *cep;
|
||||
|
||||
for(cep = encodings; *cep; cep++) {
|
||||
const content_encoding *ce = *cep;
|
||||
const struct content_encoding *ce = *cep;
|
||||
if((strncasecompare(name, ce->name, len) && !ce->name[len]) ||
|
||||
(ce->alias && strncasecompare(name, ce->alias, len) && !ce->alias[len]))
|
||||
return ce;
|
||||
|
|
@ -962,8 +963,8 @@ CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
|
|||
Curl_httpchunk_init(conn); /* init our chunky engine. */
|
||||
}
|
||||
else if(namelen) {
|
||||
const content_encoding *encoding = find_encoding(name, namelen);
|
||||
contenc_writer *writer;
|
||||
const struct content_encoding *encoding = find_encoding(name, namelen);
|
||||
struct contenc_writer *writer;
|
||||
|
||||
if(!k->writer_stack) {
|
||||
k->writer_stack = new_unencoding_writer(conn, &client_encoding, NULL);
|
||||
|
|
@ -997,7 +998,8 @@ CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
|
|||
return CURLE_NOT_BUILT_IN;
|
||||
}
|
||||
|
||||
CURLcode Curl_unencode_write(struct connectdata *conn, contenc_writer *writer,
|
||||
CURLcode Curl_unencode_write(struct connectdata *conn,
|
||||
struct contenc_writer *writer,
|
||||
const char *buf, size_t nbytes)
|
||||
{
|
||||
(void) conn;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -23,31 +23,31 @@
|
|||
***************************************************************************/
|
||||
#include "curl_setup.h"
|
||||
|
||||
/* Decoding writer. */
|
||||
typedef struct contenc_writer_s contenc_writer;
|
||||
typedef struct content_encoding_s content_encoding;
|
||||
|
||||
struct contenc_writer_s {
|
||||
const content_encoding *handler; /* Encoding handler. */
|
||||
contenc_writer *downstream; /* Downstream writer. */
|
||||
struct contenc_writer {
|
||||
const struct content_encoding *handler; /* Encoding handler. */
|
||||
struct contenc_writer *downstream; /* Downstream writer. */
|
||||
void *params; /* Encoding-specific storage (variable length). */
|
||||
};
|
||||
|
||||
/* Content encoding writer. */
|
||||
struct content_encoding_s {
|
||||
struct content_encoding {
|
||||
const char *name; /* Encoding name. */
|
||||
const char *alias; /* Encoding name alias. */
|
||||
CURLcode (*init_writer)(struct connectdata *conn, contenc_writer *writer);
|
||||
CURLcode (*unencode_write)(struct connectdata *conn, contenc_writer *writer,
|
||||
CURLcode (*init_writer)(struct connectdata *conn,
|
||||
struct contenc_writer *writer);
|
||||
CURLcode (*unencode_write)(struct connectdata *conn,
|
||||
struct contenc_writer *writer,
|
||||
const char *buf, size_t nbytes);
|
||||
void (*close_writer)(struct connectdata *conn, contenc_writer *writer);
|
||||
void (*close_writer)(struct connectdata *conn,
|
||||
struct contenc_writer *writer);
|
||||
size_t paramsize;
|
||||
};
|
||||
|
||||
|
||||
CURLcode Curl_build_unencoding_stack(struct connectdata *conn,
|
||||
const char *enclist, int maybechunked);
|
||||
CURLcode Curl_unencode_write(struct connectdata *conn, contenc_writer *writer,
|
||||
CURLcode Curl_unencode_write(struct connectdata *conn,
|
||||
struct contenc_writer *writer,
|
||||
const char *buf, size_t nbytes);
|
||||
void Curl_unencode_cleanup(struct connectdata *conn);
|
||||
char *Curl_all_content_encodings(void);
|
||||
|
|
|
|||
|
|
@ -78,10 +78,10 @@
|
|||
#endif
|
||||
|
||||
void
|
||||
Curl_freeaddrinfo(Curl_addrinfo *cahead)
|
||||
Curl_freeaddrinfo(struct Curl_addrinfo *cahead)
|
||||
{
|
||||
Curl_addrinfo *vqualifier canext;
|
||||
Curl_addrinfo *ca;
|
||||
struct Curl_addrinfo *vqualifier canext;
|
||||
struct Curl_addrinfo *ca;
|
||||
|
||||
for(ca = cahead; ca != NULL; ca = canext) {
|
||||
free(ca->ai_addr);
|
||||
|
|
@ -112,13 +112,13 @@ int
|
|||
Curl_getaddrinfo_ex(const char *nodename,
|
||||
const char *servname,
|
||||
const struct addrinfo *hints,
|
||||
Curl_addrinfo **result)
|
||||
struct Curl_addrinfo **result)
|
||||
{
|
||||
const struct addrinfo *ai;
|
||||
struct addrinfo *aihead;
|
||||
Curl_addrinfo *cafirst = NULL;
|
||||
Curl_addrinfo *calast = NULL;
|
||||
Curl_addrinfo *ca;
|
||||
struct Curl_addrinfo *cafirst = NULL;
|
||||
struct Curl_addrinfo *calast = NULL;
|
||||
struct Curl_addrinfo *ca;
|
||||
size_t ss_size;
|
||||
int error;
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ Curl_getaddrinfo_ex(const char *nodename,
|
|||
if((size_t)ai->ai_addrlen < ss_size)
|
||||
continue;
|
||||
|
||||
ca = malloc(sizeof(Curl_addrinfo));
|
||||
ca = malloc(sizeof(struct Curl_addrinfo));
|
||||
if(!ca) {
|
||||
error = EAI_MEMORY;
|
||||
break;
|
||||
|
|
@ -252,7 +252,6 @@ Curl_getaddrinfo_ex(const char *nodename,
|
|||
* struct sockaddr *ai_addr;
|
||||
* struct Curl_addrinfo *ai_next;
|
||||
* };
|
||||
* typedef struct Curl_addrinfo Curl_addrinfo;
|
||||
*
|
||||
* hostent defined in <netdb.h>
|
||||
*
|
||||
|
|
@ -269,12 +268,12 @@ Curl_getaddrinfo_ex(const char *nodename,
|
|||
* #define h_addr h_addr_list[0]
|
||||
*/
|
||||
|
||||
Curl_addrinfo *
|
||||
struct Curl_addrinfo *
|
||||
Curl_he2ai(const struct hostent *he, int port)
|
||||
{
|
||||
Curl_addrinfo *ai;
|
||||
Curl_addrinfo *prevai = NULL;
|
||||
Curl_addrinfo *firstai = NULL;
|
||||
struct Curl_addrinfo *ai;
|
||||
struct Curl_addrinfo *prevai = NULL;
|
||||
struct Curl_addrinfo *firstai = NULL;
|
||||
struct sockaddr_in *addr;
|
||||
#ifdef ENABLE_IPV6
|
||||
struct sockaddr_in6 *addr6;
|
||||
|
|
@ -299,7 +298,7 @@ Curl_he2ai(const struct hostent *he, int port)
|
|||
#endif
|
||||
ss_size = sizeof(struct sockaddr_in);
|
||||
|
||||
ai = calloc(1, sizeof(Curl_addrinfo));
|
||||
ai = calloc(1, sizeof(struct Curl_addrinfo));
|
||||
if(!ai) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
break;
|
||||
|
|
@ -389,10 +388,10 @@ struct namebuff {
|
|||
* given address/host
|
||||
*/
|
||||
|
||||
Curl_addrinfo *
|
||||
struct Curl_addrinfo *
|
||||
Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port)
|
||||
{
|
||||
Curl_addrinfo *ai;
|
||||
struct Curl_addrinfo *ai;
|
||||
|
||||
#if defined(__VMS) && \
|
||||
defined(__INITIAL_POINTER_SIZE) && (__INITIAL_POINTER_SIZE == 64)
|
||||
|
|
@ -465,7 +464,7 @@ Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port)
|
|||
* Given an IPv4 or IPv6 dotted string address, this converts it to a proper
|
||||
* allocated Curl_addrinfo struct and returns it.
|
||||
*/
|
||||
Curl_addrinfo *Curl_str2addr(char *address, int port)
|
||||
struct Curl_addrinfo *Curl_str2addr(char *address, int port)
|
||||
{
|
||||
struct in_addr in;
|
||||
if(Curl_inet_pton(AF_INET, address, &in) > 0)
|
||||
|
|
@ -488,15 +487,16 @@ Curl_addrinfo *Curl_str2addr(char *address, int port)
|
|||
* struct initialized with this path.
|
||||
* Set '*longpath' to TRUE if the error is a too long path.
|
||||
*/
|
||||
Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, bool abstract)
|
||||
struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
|
||||
bool abstract)
|
||||
{
|
||||
Curl_addrinfo *ai;
|
||||
struct Curl_addrinfo *ai;
|
||||
struct sockaddr_un *sa_un;
|
||||
size_t path_len;
|
||||
|
||||
*longpath = FALSE;
|
||||
|
||||
ai = calloc(1, sizeof(Curl_addrinfo));
|
||||
ai = calloc(1, sizeof(struct Curl_addrinfo));
|
||||
if(!ai)
|
||||
return NULL;
|
||||
ai->ai_addr = calloc(1, sizeof(struct sockaddr_un));
|
||||
|
|
@ -594,9 +594,9 @@ curl_dbg_getaddrinfo(const char *hostname,
|
|||
* Work-arounds the sin6_port is always zero bug on iOS 9.3.2 and Mac OS X
|
||||
* 10.11.5.
|
||||
*/
|
||||
void Curl_addrinfo_set_port(Curl_addrinfo *addrinfo, int port)
|
||||
void Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port)
|
||||
{
|
||||
Curl_addrinfo *ca;
|
||||
struct Curl_addrinfo *ca;
|
||||
struct sockaddr_in *addr;
|
||||
#ifdef ENABLE_IPV6
|
||||
struct sockaddr_in6 *addr6;
|
||||
|
|
|
|||
|
|
@ -58,29 +58,29 @@ struct Curl_addrinfo {
|
|||
struct sockaddr *ai_addr;
|
||||
struct Curl_addrinfo *ai_next;
|
||||
};
|
||||
typedef struct Curl_addrinfo Curl_addrinfo;
|
||||
|
||||
void
|
||||
Curl_freeaddrinfo(Curl_addrinfo *cahead);
|
||||
Curl_freeaddrinfo(struct Curl_addrinfo *cahead);
|
||||
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
int
|
||||
Curl_getaddrinfo_ex(const char *nodename,
|
||||
const char *servname,
|
||||
const struct addrinfo *hints,
|
||||
Curl_addrinfo **result);
|
||||
struct Curl_addrinfo **result);
|
||||
#endif
|
||||
|
||||
Curl_addrinfo *
|
||||
struct Curl_addrinfo *
|
||||
Curl_he2ai(const struct hostent *he, int port);
|
||||
|
||||
Curl_addrinfo *
|
||||
struct Curl_addrinfo *
|
||||
Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port);
|
||||
|
||||
Curl_addrinfo *Curl_str2addr(char *dotted, int port);
|
||||
struct Curl_addrinfo *Curl_str2addr(char *dotted, int port);
|
||||
|
||||
#ifdef USE_UNIX_SOCKETS
|
||||
Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, bool abstract);
|
||||
struct Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath,
|
||||
bool abstract);
|
||||
#endif
|
||||
|
||||
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
|
||||
|
|
@ -98,7 +98,7 @@ curl_dbg_getaddrinfo(const char *hostname, const char *service,
|
|||
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
#ifdef USE_RESOLVE_ON_IPS
|
||||
void Curl_addrinfo_set_port(Curl_addrinfo *addrinfo, int port);
|
||||
void Curl_addrinfo_set_port(struct Curl_addrinfo *addrinfo, int port);
|
||||
#else
|
||||
#define Curl_addrinfo_set_port(x,y)
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -34,37 +34,35 @@ typedef void (* HMAC_hfinal_func)(unsigned char *result, void *context);
|
|||
|
||||
|
||||
/* Per-hash function HMAC parameters. */
|
||||
|
||||
typedef struct {
|
||||
HMAC_hinit_func hmac_hinit; /* Initialize context procedure. */
|
||||
struct HMAC_params {
|
||||
HMAC_hinit_func
|
||||
hmac_hinit; /* Initialize context procedure. */
|
||||
HMAC_hupdate_func hmac_hupdate; /* Update context with data. */
|
||||
HMAC_hfinal_func hmac_hfinal; /* Get final result procedure. */
|
||||
unsigned int hmac_ctxtsize; /* Context structure size. */
|
||||
unsigned int hmac_maxkeylen; /* Maximum key length (bytes). */
|
||||
unsigned int hmac_resultlen; /* Result length (bytes). */
|
||||
} HMAC_params;
|
||||
};
|
||||
|
||||
|
||||
/* HMAC computation context. */
|
||||
|
||||
typedef struct {
|
||||
const HMAC_params *hmac_hash; /* Hash function definition. */
|
||||
struct HMAC_context {
|
||||
const struct HMAC_params *hmac_hash; /* Hash function definition. */
|
||||
void *hmac_hashctxt1; /* Hash function context 1. */
|
||||
void *hmac_hashctxt2; /* Hash function context 2. */
|
||||
} HMAC_context;
|
||||
};
|
||||
|
||||
|
||||
/* Prototypes. */
|
||||
|
||||
HMAC_context * Curl_HMAC_init(const HMAC_params *hashparams,
|
||||
const unsigned char *key,
|
||||
unsigned int keylen);
|
||||
int Curl_HMAC_update(HMAC_context *context,
|
||||
struct HMAC_context *Curl_HMAC_init(const struct HMAC_params *hashparams,
|
||||
const unsigned char *key,
|
||||
unsigned int keylen);
|
||||
int Curl_HMAC_update(struct HMAC_context *context,
|
||||
const unsigned char *data,
|
||||
unsigned int len);
|
||||
int Curl_HMAC_final(HMAC_context *context, unsigned char *result);
|
||||
int Curl_HMAC_final(struct HMAC_context *context, unsigned char *result);
|
||||
|
||||
CURLcode Curl_hmacit(const HMAC_params *hashparams,
|
||||
CURLcode Curl_hmacit(const struct HMAC_params *hashparams,
|
||||
const unsigned char *key, const size_t keylen,
|
||||
const unsigned char *data, const size_t datalen,
|
||||
unsigned char *output);
|
||||
|
|
|
|||
|
|
@ -33,30 +33,30 @@ typedef void (* Curl_MD5_update_func)(void *context,
|
|||
unsigned int len);
|
||||
typedef void (* Curl_MD5_final_func)(unsigned char *result, void *context);
|
||||
|
||||
typedef struct {
|
||||
struct MD5_params {
|
||||
Curl_MD5_init_func md5_init_func; /* Initialize context procedure */
|
||||
Curl_MD5_update_func md5_update_func; /* Update context with data */
|
||||
Curl_MD5_final_func md5_final_func; /* Get final result procedure */
|
||||
unsigned int md5_ctxtsize; /* Context structure size */
|
||||
unsigned int md5_resultlen; /* Result length (bytes) */
|
||||
} MD5_params;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
const MD5_params *md5_hash; /* Hash function definition */
|
||||
struct MD5_context {
|
||||
const struct MD5_params *md5_hash; /* Hash function definition */
|
||||
void *md5_hashctx; /* Hash function context */
|
||||
} MD5_context;
|
||||
};
|
||||
|
||||
extern const MD5_params Curl_DIGEST_MD5[1];
|
||||
extern const HMAC_params Curl_HMAC_MD5[1];
|
||||
extern const struct MD5_params Curl_DIGEST_MD5[1];
|
||||
extern const struct HMAC_params Curl_HMAC_MD5[1];
|
||||
|
||||
void Curl_md5it(unsigned char *output, const unsigned char *input,
|
||||
const size_t len);
|
||||
|
||||
MD5_context * Curl_MD5_init(const MD5_params *md5params);
|
||||
CURLcode Curl_MD5_update(MD5_context *context,
|
||||
struct MD5_context *Curl_MD5_init(const struct MD5_params *md5params);
|
||||
CURLcode Curl_MD5_update(struct MD5_context *context,
|
||||
const unsigned char *data,
|
||||
unsigned int len);
|
||||
CURLcode Curl_MD5_final(MD5_context *context, unsigned char *result);
|
||||
CURLcode Curl_MD5_final(struct MD5_context *context, unsigned char *result);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
18
lib/doh.c
18
lib/doh.c
|
|
@ -373,10 +373,10 @@ static CURLcode dohprobe(struct Curl_easy *data,
|
|||
* 'Curl_addrinfo *' with the address information.
|
||||
*/
|
||||
|
||||
Curl_addrinfo *Curl_doh(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
struct Curl_addrinfo *Curl_doh(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
{
|
||||
struct Curl_easy *data = conn->data;
|
||||
CURLcode result = CURLE_OK;
|
||||
|
|
@ -790,12 +790,12 @@ static void showdoh(struct Curl_easy *data,
|
|||
* must be an associated call later to Curl_freeaddrinfo().
|
||||
*/
|
||||
|
||||
static Curl_addrinfo *
|
||||
static struct Curl_addrinfo *
|
||||
doh2ai(const struct dohentry *de, const char *hostname, int port)
|
||||
{
|
||||
Curl_addrinfo *ai;
|
||||
Curl_addrinfo *prevai = NULL;
|
||||
Curl_addrinfo *firstai = NULL;
|
||||
struct Curl_addrinfo *ai;
|
||||
struct Curl_addrinfo *prevai = NULL;
|
||||
struct Curl_addrinfo *firstai = NULL;
|
||||
struct sockaddr_in *addr;
|
||||
#ifdef ENABLE_IPV6
|
||||
struct sockaddr_in6 *addr6;
|
||||
|
|
@ -824,7 +824,7 @@ doh2ai(const struct dohentry *de, const char *hostname, int port)
|
|||
addrtype = AF_INET;
|
||||
}
|
||||
|
||||
ai = calloc(1, sizeof(Curl_addrinfo));
|
||||
ai = calloc(1, sizeof(struct Curl_addrinfo));
|
||||
if(!ai) {
|
||||
result = CURLE_OUT_OF_MEMORY;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@
|
|||
* and returns a 'Curl_addrinfo *' with the address information.
|
||||
*/
|
||||
|
||||
Curl_addrinfo *Curl_doh(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp);
|
||||
struct Curl_addrinfo *Curl_doh(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp);
|
||||
|
||||
CURLcode Curl_doh_is_resolved(struct connectdata *conn,
|
||||
struct Curl_dns_entry **dns);
|
||||
|
|
|
|||
|
|
@ -123,11 +123,11 @@ AddHttpPost(char *name, size_t namelength,
|
|||
* parent_form_info is NULL.
|
||||
*
|
||||
***************************************************************************/
|
||||
static FormInfo * AddFormInfo(char *value,
|
||||
char *contenttype,
|
||||
FormInfo *parent_form_info)
|
||||
static struct FormInfo *AddFormInfo(char *value,
|
||||
char *contenttype,
|
||||
struct FormInfo *parent_form_info)
|
||||
{
|
||||
FormInfo *form_info;
|
||||
struct FormInfo *form_info;
|
||||
form_info = calloc(1, sizeof(struct FormInfo));
|
||||
if(form_info) {
|
||||
if(value)
|
||||
|
|
@ -204,7 +204,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
struct curl_httppost **last_post,
|
||||
va_list params)
|
||||
{
|
||||
FormInfo *first_form, *current_form, *form = NULL;
|
||||
struct FormInfo *first_form, *current_form, *form = NULL;
|
||||
CURLFORMcode return_value = CURL_FORMADD_OK;
|
||||
const char *prevtype = NULL;
|
||||
struct curl_httppost *post = NULL;
|
||||
|
|
@ -521,7 +521,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
if(CURL_FORMADD_OK != return_value) {
|
||||
/* On error, free allocated fields for all nodes of the FormInfo linked
|
||||
list without deallocating nodes. List nodes are deallocated later on */
|
||||
FormInfo *ptr;
|
||||
struct FormInfo *ptr;
|
||||
for(ptr = first_form; ptr != NULL; ptr = ptr->more) {
|
||||
if(ptr->name_alloc) {
|
||||
Curl_safefree(ptr->name);
|
||||
|
|
@ -650,7 +650,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
/* On error, free allocated fields for nodes of the FormInfo linked
|
||||
list which are not already owned by the httppost linked list
|
||||
without deallocating nodes. List nodes are deallocated later on */
|
||||
FormInfo *ptr;
|
||||
struct FormInfo *ptr;
|
||||
for(ptr = form; ptr != NULL; ptr = ptr->more) {
|
||||
if(ptr->name_alloc) {
|
||||
Curl_safefree(ptr->name);
|
||||
|
|
@ -676,7 +676,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||
fields given that these have either been deallocated or are owned
|
||||
now by the httppost linked list */
|
||||
while(first_form) {
|
||||
FormInfo *ptr = first_form->more;
|
||||
struct FormInfo *ptr = first_form->more;
|
||||
free(first_form);
|
||||
first_form = ptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
#ifndef CURL_DISABLE_MIME
|
||||
|
||||
/* used by FormAdd for temporary storage */
|
||||
typedef struct FormInfo {
|
||||
struct FormInfo {
|
||||
char *name;
|
||||
bool name_alloc;
|
||||
size_t namelength;
|
||||
|
|
@ -45,7 +45,7 @@ typedef struct FormInfo {
|
|||
char *userp; /* pointer for the read callback */
|
||||
struct curl_slist *contentheader;
|
||||
struct FormInfo *more;
|
||||
} FormInfo;
|
||||
};
|
||||
|
||||
CURLcode Curl_getformdata(struct Curl_easy *data,
|
||||
curl_mimepart *,
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ static CURLcode ftp_parse_url_path(struct connectdata *conn);
|
|||
static CURLcode ftp_regular_transfer(struct connectdata *conn, bool *done);
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
static void ftp_pasv_verbose(struct connectdata *conn,
|
||||
Curl_addrinfo *ai,
|
||||
struct Curl_addrinfo *ai,
|
||||
char *newhost, /* ascii version */
|
||||
int port);
|
||||
#endif
|
||||
|
|
@ -916,7 +916,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
|
|||
char myhost[MAX_IPADR_LEN + 1] = "";
|
||||
|
||||
struct Curl_sockaddr_storage ss;
|
||||
Curl_addrinfo *res, *ai;
|
||||
struct Curl_addrinfo *res, *ai;
|
||||
curl_socklen_t sslen;
|
||||
char hbuf[NI_MAXHOST];
|
||||
struct sockaddr *sa = (struct sockaddr *)&ss;
|
||||
|
|
@ -3445,7 +3445,7 @@ static CURLcode ftp_nb_type(struct connectdata *conn,
|
|||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
static void
|
||||
ftp_pasv_verbose(struct connectdata *conn,
|
||||
Curl_addrinfo *ai,
|
||||
struct Curl_addrinfo *ai,
|
||||
char *newhost, /* ascii version */
|
||||
int port)
|
||||
{
|
||||
|
|
|
|||
17
lib/hmac.c
17
lib/hmac.c
|
|
@ -48,13 +48,13 @@ static const unsigned char hmac_opad = 0x5C;
|
|||
|
||||
|
||||
|
||||
HMAC_context *
|
||||
Curl_HMAC_init(const HMAC_params * hashparams,
|
||||
struct HMAC_context *
|
||||
Curl_HMAC_init(const struct HMAC_params *hashparams,
|
||||
const unsigned char *key,
|
||||
unsigned int keylen)
|
||||
{
|
||||
size_t i;
|
||||
HMAC_context *ctxt;
|
||||
struct HMAC_context *ctxt;
|
||||
unsigned char *hkey;
|
||||
unsigned char b;
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ Curl_HMAC_init(const HMAC_params * hashparams,
|
|||
return ctxt;
|
||||
}
|
||||
|
||||
int Curl_HMAC_update(HMAC_context * ctxt,
|
||||
int Curl_HMAC_update(struct HMAC_context *ctxt,
|
||||
const unsigned char *data,
|
||||
unsigned int len)
|
||||
{
|
||||
|
|
@ -111,9 +111,9 @@ int Curl_HMAC_update(HMAC_context * ctxt,
|
|||
}
|
||||
|
||||
|
||||
int Curl_HMAC_final(HMAC_context *ctxt, unsigned char *result)
|
||||
int Curl_HMAC_final(struct HMAC_context *ctxt, unsigned char *result)
|
||||
{
|
||||
const HMAC_params * hashparams = ctxt->hmac_hash;
|
||||
const struct HMAC_params *hashparams = ctxt->hmac_hash;
|
||||
|
||||
/* Do not get result if called with a null parameter: only release
|
||||
storage. */
|
||||
|
|
@ -147,12 +147,13 @@ int Curl_HMAC_final(HMAC_context *ctxt, unsigned char *result)
|
|||
*
|
||||
* Returns CURLE_OK on success.
|
||||
*/
|
||||
CURLcode Curl_hmacit(const HMAC_params *hashparams,
|
||||
CURLcode Curl_hmacit(const struct HMAC_params *hashparams,
|
||||
const unsigned char *key, const size_t keylen,
|
||||
const unsigned char *data, const size_t datalen,
|
||||
unsigned char *output)
|
||||
{
|
||||
HMAC_context *ctxt = Curl_HMAC_init(hashparams, key, curlx_uztoui(keylen));
|
||||
struct HMAC_context *ctxt =
|
||||
Curl_HMAC_init(hashparams, key, curlx_uztoui(keylen));
|
||||
|
||||
if(!ctxt)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -117,10 +117,10 @@ CURLcode Curl_addrinfo_callback(struct connectdata *conn,
|
|||
* name resolve layers (selected at build-time). They all take this same set
|
||||
* of arguments
|
||||
*/
|
||||
Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
{
|
||||
return Curl_resolver_getaddrinfo(conn, hostname, port, waitp);
|
||||
}
|
||||
|
|
|
|||
22
lib/hostip.c
22
lib/hostip.c
|
|
@ -120,7 +120,7 @@ static void freednsentry(void *freethis);
|
|||
/*
|
||||
* Return # of addresses in a Curl_addrinfo struct
|
||||
*/
|
||||
int Curl_num_addresses(const Curl_addrinfo *addr)
|
||||
int Curl_num_addresses(const struct Curl_addrinfo *addr)
|
||||
{
|
||||
int i = 0;
|
||||
while(addr) {
|
||||
|
|
@ -137,8 +137,8 @@ int Curl_num_addresses(const Curl_addrinfo *addr)
|
|||
*
|
||||
* If the conversion fails, it returns NULL.
|
||||
*/
|
||||
const char *
|
||||
Curl_printable_address(const Curl_addrinfo *ai, char *buf, size_t bufsize)
|
||||
const char *Curl_printable_address(const struct Curl_addrinfo *ai, char *buf,
|
||||
size_t bufsize)
|
||||
{
|
||||
const struct sockaddr_in *sa4;
|
||||
const struct in_addr *ipaddr4;
|
||||
|
|
@ -337,7 +337,7 @@ Curl_fetch_addr(struct connectdata *conn,
|
|||
|
||||
#ifndef CURL_DISABLE_SHUFFLE_DNS
|
||||
UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
||||
Curl_addrinfo **addr);
|
||||
struct Curl_addrinfo **addr);
|
||||
/*
|
||||
* Curl_shuffle_addr() shuffles the order of addresses in a 'Curl_addrinfo'
|
||||
* struct by re-linking its linked list.
|
||||
|
|
@ -351,13 +351,13 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
|||
* @unittest: 1608
|
||||
*/
|
||||
UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
||||
Curl_addrinfo **addr)
|
||||
struct Curl_addrinfo **addr)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
const int num_addrs = Curl_num_addresses(*addr);
|
||||
|
||||
if(num_addrs > 1) {
|
||||
Curl_addrinfo **nodes;
|
||||
struct Curl_addrinfo **nodes;
|
||||
infof(data, "Shuffling %i addresses", num_addrs);
|
||||
|
||||
nodes = malloc(num_addrs*sizeof(*nodes));
|
||||
|
|
@ -376,7 +376,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
|||
if(rnd) {
|
||||
/* Fisher-Yates shuffle */
|
||||
if(Curl_rand(data, (unsigned char *)rnd, rnd_size) == CURLE_OK) {
|
||||
Curl_addrinfo *swap_tmp;
|
||||
struct Curl_addrinfo *swap_tmp;
|
||||
for(i = num_addrs - 1; i > 0; i--) {
|
||||
swap_tmp = nodes[rnd[i] % (i + 1)];
|
||||
nodes[rnd[i] % (i + 1)] = nodes[i];
|
||||
|
|
@ -415,7 +415,7 @@ UNITTEST CURLcode Curl_shuffle_addr(struct Curl_easy *data,
|
|||
*/
|
||||
struct Curl_dns_entry *
|
||||
Curl_cache_addr(struct Curl_easy *data,
|
||||
Curl_addrinfo *addr,
|
||||
struct Curl_addrinfo *addr,
|
||||
const char *hostname,
|
||||
int port)
|
||||
{
|
||||
|
|
@ -513,7 +513,7 @@ enum resolve_t Curl_resolv(struct connectdata *conn,
|
|||
if(!dns) {
|
||||
/* The entry was not in the cache. Resolve it to IP address */
|
||||
|
||||
Curl_addrinfo *addr = NULL;
|
||||
struct Curl_addrinfo *addr = NULL;
|
||||
int respwait = 0;
|
||||
#ifndef USE_RESOLVE_ON_IPS
|
||||
struct in_addr in;
|
||||
|
|
@ -890,7 +890,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
|
|||
}
|
||||
else {
|
||||
struct Curl_dns_entry *dns;
|
||||
Curl_addrinfo *head = NULL, *tail = NULL;
|
||||
struct Curl_addrinfo *head = NULL, *tail = NULL;
|
||||
size_t entry_len;
|
||||
char address[64];
|
||||
#if !defined(CURL_DISABLE_VERBOSE_STRINGS)
|
||||
|
|
@ -924,7 +924,7 @@ CURLcode Curl_loadhostpairs(struct Curl_easy *data)
|
|||
|
||||
while(*end_ptr) {
|
||||
size_t alen;
|
||||
Curl_addrinfo *ai;
|
||||
struct Curl_addrinfo *ai;
|
||||
|
||||
addr_begin = end_ptr + 1;
|
||||
addr_end = strchr(addr_begin, ',');
|
||||
|
|
|
|||
20
lib/hostip.h
20
lib/hostip.h
|
|
@ -64,7 +64,7 @@ struct connectdata;
|
|||
struct curl_hash *Curl_global_host_cache_init(void);
|
||||
|
||||
struct Curl_dns_entry {
|
||||
Curl_addrinfo *addr;
|
||||
struct Curl_addrinfo *addr;
|
||||
/* timestamp == 0 -- CURLOPT_RESOLVE entry, doesn't timeout */
|
||||
time_t timestamp;
|
||||
/* use-counter, use Curl_resolv_unlock to release reference */
|
||||
|
|
@ -117,10 +117,10 @@ bool Curl_ipvalid(struct connectdata *conn);
|
|||
* name resolve layers (selected at build-time). They all take this same set
|
||||
* of arguments
|
||||
*/
|
||||
Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp);
|
||||
struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp);
|
||||
|
||||
|
||||
/* unlock a previously resolved dns entry */
|
||||
|
|
@ -134,7 +134,7 @@ int Curl_mk_dnscache(struct curl_hash *hash);
|
|||
void Curl_hostcache_prune(struct Curl_easy *data);
|
||||
|
||||
/* Return # of addresses in a Curl_addrinfo struct */
|
||||
int Curl_num_addresses(const Curl_addrinfo *addr);
|
||||
int Curl_num_addresses(const struct Curl_addrinfo *addr);
|
||||
|
||||
#if defined(CURLDEBUG) && defined(HAVE_GETNAMEINFO)
|
||||
int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa,
|
||||
|
|
@ -146,7 +146,7 @@ int curl_dogetnameinfo(GETNAMEINFO_QUAL_ARG1 GETNAMEINFO_TYPE_ARG1 sa,
|
|||
#endif
|
||||
|
||||
/* IPv4 threadsafe resolve function used for synch and asynch builds */
|
||||
Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port);
|
||||
struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port);
|
||||
|
||||
CURLcode Curl_once_resolved(struct connectdata *conn, bool *protocol_connect);
|
||||
|
||||
|
|
@ -158,14 +158,14 @@ CURLcode Curl_once_resolved(struct connectdata *conn, bool *protocol_connect);
|
|||
*/
|
||||
CURLcode Curl_addrinfo_callback(struct connectdata *conn,
|
||||
int status,
|
||||
Curl_addrinfo *ai);
|
||||
struct Curl_addrinfo *ai);
|
||||
|
||||
/*
|
||||
* Curl_printable_address() returns a printable version of the 1st address
|
||||
* given in the 'ip' argument. The result will be stored in the buf that is
|
||||
* bufsize bytes big.
|
||||
*/
|
||||
const char *Curl_printable_address(const Curl_addrinfo *ip,
|
||||
const char *Curl_printable_address(const struct Curl_addrinfo *ip,
|
||||
char *buf, size_t bufsize);
|
||||
|
||||
/*
|
||||
|
|
@ -187,7 +187,7 @@ Curl_fetch_addr(struct connectdata *conn,
|
|||
* Returns the Curl_dns_entry entry pointer or NULL if the storage failed.
|
||||
*/
|
||||
struct Curl_dns_entry *
|
||||
Curl_cache_addr(struct Curl_easy *data, Curl_addrinfo *addr,
|
||||
Curl_cache_addr(struct Curl_easy *data, struct Curl_addrinfo *addr,
|
||||
const char *hostname, int port);
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
|
|
|
|||
|
|
@ -88,12 +88,12 @@ bool Curl_ipvalid(struct connectdata *conn)
|
|||
* flavours have thread-safe versions of the plain gethostbyname() etc.
|
||||
*
|
||||
*/
|
||||
Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
{
|
||||
Curl_addrinfo *ai = NULL;
|
||||
struct Curl_addrinfo *ai = NULL;
|
||||
|
||||
#ifdef CURL_DISABLE_VERBOSE_STRINGS
|
||||
(void)conn;
|
||||
|
|
@ -119,13 +119,13 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
|||
* implying that only threadsafe code and function calls may be used.
|
||||
*
|
||||
*/
|
||||
Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
||||
int port)
|
||||
struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
||||
int port)
|
||||
{
|
||||
#if !defined(HAVE_GETADDRINFO_THREADSAFE) && defined(HAVE_GETHOSTBYNAME_R_3)
|
||||
int res;
|
||||
#endif
|
||||
Curl_addrinfo *ai = NULL;
|
||||
struct Curl_addrinfo *ai = NULL;
|
||||
struct hostent *h = NULL;
|
||||
struct hostent *buf = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,8 @@ bool Curl_ipvalid(struct connectdata *conn)
|
|||
#if defined(CURLRES_SYNCH)
|
||||
|
||||
#ifdef DEBUG_ADDRINFO
|
||||
static void dump_addrinfo(struct connectdata *conn, const Curl_addrinfo *ai)
|
||||
static void dump_addrinfo(struct connectdata *conn,
|
||||
const struct Curl_addrinfo *ai)
|
||||
{
|
||||
printf("dump_addrinfo:\n");
|
||||
for(; ai; ai = ai->ai_next) {
|
||||
|
|
@ -132,13 +133,13 @@ static void dump_addrinfo(struct connectdata *conn, const Curl_addrinfo *ai)
|
|||
* memory we need to free after use. That memory *MUST* be freed with
|
||||
* Curl_freeaddrinfo(), nothing else.
|
||||
*/
|
||||
Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
struct Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
|
||||
const char *hostname,
|
||||
int port,
|
||||
int *waitp)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
Curl_addrinfo *res;
|
||||
struct Curl_addrinfo *res;
|
||||
int error;
|
||||
char sbuf[12];
|
||||
char *sbufptr = NULL;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
/* Use our own implementation. */
|
||||
|
||||
typedef struct {
|
||||
struct ldap_urldesc {
|
||||
char *lud_host;
|
||||
int lud_port;
|
||||
#if defined(USE_WIN32_LDAP)
|
||||
|
|
@ -95,10 +95,10 @@ typedef struct {
|
|||
size_t lud_attrs_dups; /* how many were dup'ed, this field is not in the
|
||||
"real" struct so can only be used in code
|
||||
without HAVE_LDAP_URL_PARSE defined */
|
||||
} CURL_LDAPURLDesc;
|
||||
};
|
||||
|
||||
#undef LDAPURLDesc
|
||||
#define LDAPURLDesc CURL_LDAPURLDesc
|
||||
#define LDAPURLDesc struct ldap_urldesc
|
||||
|
||||
static int _ldap_url_parse(const struct connectdata *conn,
|
||||
LDAPURLDesc **ludp);
|
||||
|
|
|
|||
15
lib/md4.c
15
lib/md4.c
|
|
@ -139,10 +139,11 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
|
|||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
typedef struct {
|
||||
struct md4_ctx {
|
||||
HCRYPTPROV hCryptProv;
|
||||
HCRYPTHASH hHash;
|
||||
} MD4_CTX;
|
||||
};
|
||||
typedef struct md4_ctx MD4_CTX;
|
||||
|
||||
static void MD4_Init(MD4_CTX *ctx)
|
||||
{
|
||||
|
|
@ -184,10 +185,11 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
|
|||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
typedef struct {
|
||||
struct md4_ctx {
|
||||
void *data;
|
||||
unsigned long size;
|
||||
} MD4_CTX;
|
||||
};
|
||||
typedef struct md4_ctx MD4_CTX;
|
||||
|
||||
static void MD4_Init(MD4_CTX *ctx)
|
||||
{
|
||||
|
|
@ -266,12 +268,13 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
|
|||
/* Any 32-bit or wider unsigned integer data type will do */
|
||||
typedef unsigned int MD4_u32plus;
|
||||
|
||||
typedef struct {
|
||||
struct md4_ctx {
|
||||
MD4_u32plus lo, hi;
|
||||
MD4_u32plus a, b, c, d;
|
||||
unsigned char buffer[64];
|
||||
MD4_u32plus block[16];
|
||||
} MD4_CTX;
|
||||
};
|
||||
typedef struct md4_ctx MD4_CTX;
|
||||
|
||||
static void MD4_Init(MD4_CTX *ctx);
|
||||
static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size);
|
||||
|
|
|
|||
22
lib/md5.c
22
lib/md5.c
|
|
@ -179,10 +179,11 @@ static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
|
|||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
typedef struct {
|
||||
struct md5_ctx {
|
||||
HCRYPTPROV hCryptProv;
|
||||
HCRYPTHASH hHash;
|
||||
} MD5_CTX;
|
||||
};
|
||||
typedef struct md5_ctx MD5_CTX;
|
||||
|
||||
static void MD5_Init(MD5_CTX *ctx)
|
||||
{
|
||||
|
|
@ -261,12 +262,13 @@ static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
|
|||
/* Any 32-bit or wider unsigned integer data type will do */
|
||||
typedef unsigned int MD5_u32plus;
|
||||
|
||||
typedef struct {
|
||||
struct md5_ctx {
|
||||
MD5_u32plus lo, hi;
|
||||
MD5_u32plus a, b, c, d;
|
||||
unsigned char buffer[64];
|
||||
MD5_u32plus block[16];
|
||||
} MD5_CTX;
|
||||
};
|
||||
typedef struct md5_ctx MD5_CTX;
|
||||
|
||||
static void MD5_Init(MD5_CTX *ctx);
|
||||
static void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
|
||||
|
|
@ -528,7 +530,7 @@ static void MD5_Final(unsigned char *result, MD5_CTX *ctx)
|
|||
|
||||
#endif /* CRYPTO LIBS */
|
||||
|
||||
const HMAC_params Curl_HMAC_MD5[] = {
|
||||
const struct HMAC_params Curl_HMAC_MD5[] = {
|
||||
{
|
||||
/* Hash initialization function. */
|
||||
CURLX_FUNCTION_CAST(HMAC_hinit_func, MD5_Init),
|
||||
|
|
@ -545,7 +547,7 @@ const HMAC_params Curl_HMAC_MD5[] = {
|
|||
}
|
||||
};
|
||||
|
||||
const MD5_params Curl_DIGEST_MD5[] = {
|
||||
const struct MD5_params Curl_DIGEST_MD5[] = {
|
||||
{
|
||||
/* Digest initialization function */
|
||||
CURLX_FUNCTION_CAST(Curl_MD5_init_func, MD5_Init),
|
||||
|
|
@ -573,9 +575,9 @@ void Curl_md5it(unsigned char *outbuffer, const unsigned char *input,
|
|||
MD5_Final(outbuffer, &ctx);
|
||||
}
|
||||
|
||||
MD5_context *Curl_MD5_init(const MD5_params *md5params)
|
||||
struct MD5_context *Curl_MD5_init(const struct MD5_params *md5params)
|
||||
{
|
||||
MD5_context *ctxt;
|
||||
struct MD5_context *ctxt;
|
||||
|
||||
/* Create MD5 context */
|
||||
ctxt = malloc(sizeof(*ctxt));
|
||||
|
|
@ -597,7 +599,7 @@ MD5_context *Curl_MD5_init(const MD5_params *md5params)
|
|||
return ctxt;
|
||||
}
|
||||
|
||||
CURLcode Curl_MD5_update(MD5_context *context,
|
||||
CURLcode Curl_MD5_update(struct MD5_context *context,
|
||||
const unsigned char *data,
|
||||
unsigned int len)
|
||||
{
|
||||
|
|
@ -606,7 +608,7 @@ CURLcode Curl_MD5_update(MD5_context *context,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
CURLcode Curl_MD5_final(MD5_context *context, unsigned char *result)
|
||||
CURLcode Curl_MD5_final(struct MD5_context *context, unsigned char *result)
|
||||
{
|
||||
(*context->md5_hash->md5_final_func)(result, context->md5_hashctx);
|
||||
|
||||
|
|
|
|||
25
lib/mime.c
25
lib/mime.c
|
|
@ -71,7 +71,7 @@ static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
|
|||
curl_mimepart *part);
|
||||
static curl_off_t encoder_qp_size(curl_mimepart *part);
|
||||
|
||||
static const mime_encoder encoders[] = {
|
||||
static const struct mime_encoder encoders[] = {
|
||||
{"binary", encoder_nop_read, encoder_nop_size},
|
||||
{"8bit", encoder_nop_read, encoder_nop_size},
|
||||
{"7bit", encoder_7bit_read, encoder_nop_size},
|
||||
|
|
@ -269,7 +269,8 @@ static char *Curl_basename(char *path)
|
|||
|
||||
|
||||
/* Set readback state. */
|
||||
static void mimesetstate(mime_state *state, enum mimestate tok, void *ptr)
|
||||
static void mimesetstate(struct mime_state *state,
|
||||
enum mimestate tok, void *ptr)
|
||||
{
|
||||
state->state = tok;
|
||||
state->ptr = ptr;
|
||||
|
|
@ -342,7 +343,7 @@ static char *strippath(const char *fullfile)
|
|||
}
|
||||
|
||||
/* Initialize data encoder state. */
|
||||
static void cleanup_encoder_state(mime_encoder_state *p)
|
||||
static void cleanup_encoder_state(struct mime_encoder_state *p)
|
||||
{
|
||||
p->pos = 0;
|
||||
p->bufbeg = 0;
|
||||
|
|
@ -352,9 +353,9 @@ static void cleanup_encoder_state(mime_encoder_state *p)
|
|||
|
||||
/* Dummy encoder. This is used for 8bit and binary content encodings. */
|
||||
static size_t encoder_nop_read(char *buffer, size_t size, bool ateof,
|
||||
curl_mimepart *part)
|
||||
struct curl_mimepart *part)
|
||||
{
|
||||
mime_encoder_state *st = &part->encstate;
|
||||
struct mime_encoder_state *st = &part->encstate;
|
||||
size_t insize = st->bufend - st->bufbeg;
|
||||
|
||||
(void) ateof;
|
||||
|
|
@ -382,7 +383,7 @@ static curl_off_t encoder_nop_size(curl_mimepart *part)
|
|||
static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
|
||||
curl_mimepart *part)
|
||||
{
|
||||
mime_encoder_state *st = &part->encstate;
|
||||
struct mime_encoder_state *st = &part->encstate;
|
||||
size_t cursize = st->bufend - st->bufbeg;
|
||||
|
||||
(void) ateof;
|
||||
|
|
@ -408,7 +409,7 @@ static size_t encoder_7bit_read(char *buffer, size_t size, bool ateof,
|
|||
static size_t encoder_base64_read(char *buffer, size_t size, bool ateof,
|
||||
curl_mimepart *part)
|
||||
{
|
||||
mime_encoder_state *st = &part->encstate;
|
||||
struct mime_encoder_state *st = &part->encstate;
|
||||
size_t cursize = 0;
|
||||
int i;
|
||||
char *ptr = buffer;
|
||||
|
|
@ -512,7 +513,7 @@ static curl_off_t encoder_base64_size(curl_mimepart *part)
|
|||
* Check if a CRLF or end of data is in input buffer at current position + n.
|
||||
* Return -1 if more data needed, 1 if CRLF or end of data, else 0.
|
||||
*/
|
||||
static int qp_lookahead_eol(mime_encoder_state *st, int ateof, size_t n)
|
||||
static int qp_lookahead_eol(struct mime_encoder_state *st, int ateof, size_t n)
|
||||
{
|
||||
n += st->bufbeg;
|
||||
if(n >= st->bufend && ateof)
|
||||
|
|
@ -529,7 +530,7 @@ static int qp_lookahead_eol(mime_encoder_state *st, int ateof, size_t n)
|
|||
static size_t encoder_qp_read(char *buffer, size_t size, bool ateof,
|
||||
curl_mimepart *part)
|
||||
{
|
||||
mime_encoder_state *st = &part->encstate;
|
||||
struct mime_encoder_state *st = &part->encstate;
|
||||
char *ptr = buffer;
|
||||
size_t cursize = 0;
|
||||
int softlinebreak;
|
||||
|
|
@ -740,7 +741,7 @@ static void mime_file_free(void *ptr)
|
|||
/* Argument is a pointer to the mime structure. */
|
||||
|
||||
/* Readback a byte string segment. */
|
||||
static size_t readback_bytes(mime_state *state,
|
||||
static size_t readback_bytes(struct mime_state *state,
|
||||
char *buffer, size_t bufsize,
|
||||
const char *bytes, size_t numbytes,
|
||||
const char *trail)
|
||||
|
|
@ -839,7 +840,7 @@ static size_t read_part_content(curl_mimepart *part,
|
|||
static size_t read_encoded_part_content(curl_mimepart *part, char *buffer,
|
||||
size_t bufsize, bool *hasread)
|
||||
{
|
||||
mime_encoder_state *st = &part->encstate;
|
||||
struct mime_encoder_state *st = &part->encstate;
|
||||
size_t cursize = 0;
|
||||
size_t sz;
|
||||
bool ateof = FALSE;
|
||||
|
|
@ -1502,7 +1503,7 @@ CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype)
|
|||
CURLcode curl_mime_encoder(curl_mimepart *part, const char *encoding)
|
||||
{
|
||||
CURLcode result = CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
const mime_encoder *mep;
|
||||
const struct mime_encoder *mep;
|
||||
|
||||
if(!part)
|
||||
return result;
|
||||
|
|
|
|||
44
lib/mime.h
44
lib/mime.h
|
|
@ -69,43 +69,43 @@ enum mimestrategy {
|
|||
};
|
||||
|
||||
/* Content transfer encoder. */
|
||||
typedef struct {
|
||||
struct mime_encoder {
|
||||
const char * name; /* Encoding name. */
|
||||
size_t (*encodefunc)(char *buffer, size_t size, bool ateof,
|
||||
curl_mimepart *part); /* Encoded read. */
|
||||
curl_off_t (*sizefunc)(curl_mimepart *part); /* Encoded size. */
|
||||
} mime_encoder;
|
||||
};
|
||||
|
||||
/* Content transfer encoder state. */
|
||||
typedef struct {
|
||||
struct mime_encoder_state {
|
||||
size_t pos; /* Position on output line. */
|
||||
size_t bufbeg; /* Next data index in input buffer. */
|
||||
size_t bufend; /* First unused byte index in input buffer. */
|
||||
char buf[ENCODING_BUFFER_SIZE]; /* Input buffer. */
|
||||
} mime_encoder_state;
|
||||
};
|
||||
|
||||
/* Mime readback state. */
|
||||
typedef struct {
|
||||
struct mime_state {
|
||||
enum mimestate state; /* Current state token. */
|
||||
void *ptr; /* State-dependent pointer. */
|
||||
curl_off_t offset; /* State-dependent offset. */
|
||||
} mime_state;
|
||||
};
|
||||
|
||||
/* minimum buffer size for the boundary string */
|
||||
#define MIME_BOUNDARY_LEN (24 + MIME_RAND_BOUNDARY_CHARS + 1)
|
||||
|
||||
/* A mime multipart. */
|
||||
struct curl_mime_s {
|
||||
struct curl_mime {
|
||||
struct Curl_easy *easy; /* The associated easy handle. */
|
||||
curl_mimepart *parent; /* Parent part. */
|
||||
curl_mimepart *firstpart; /* First part. */
|
||||
curl_mimepart *lastpart; /* Last part. */
|
||||
char boundary[MIME_BOUNDARY_LEN]; /* The part boundary. */
|
||||
mime_state state; /* Current readback state. */
|
||||
struct mime_state state; /* Current readback state. */
|
||||
};
|
||||
|
||||
/* A mime part. */
|
||||
struct curl_mimepart_s {
|
||||
struct curl_mimepart {
|
||||
struct Curl_easy *easy; /* The associated easy handle. */
|
||||
curl_mime *parent; /* Parent mime structure. */
|
||||
curl_mimepart *nextpart; /* Forward linked list. */
|
||||
|
|
@ -123,9 +123,9 @@ struct curl_mimepart_s {
|
|||
char *name; /* Data name. */
|
||||
curl_off_t datasize; /* Expected data size. */
|
||||
unsigned int flags; /* Flags. */
|
||||
mime_state state; /* Current readback state. */
|
||||
const mime_encoder *encoder; /* Content data encoder. */
|
||||
mime_encoder_state encstate; /* Data encoder state. */
|
||||
struct mime_state state; /* Current readback state. */
|
||||
const struct mime_encoder *encoder; /* Content data encoder. */
|
||||
struct mime_encoder_state encstate; /* Data encoder state. */
|
||||
size_t lastreadstatus; /* Last read callback returned status. */
|
||||
};
|
||||
|
||||
|
|
@ -135,21 +135,23 @@ CURLcode Curl_mime_add_header(struct curl_slist **slp, const char *fmt, ...);
|
|||
!defined(CURL_DISABLE_SMTP) || !defined(CURL_DISABLE_IMAP)
|
||||
|
||||
/* Prototypes. */
|
||||
void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy);
|
||||
void Curl_mime_cleanpart(curl_mimepart *part);
|
||||
CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src);
|
||||
CURLcode Curl_mime_set_subparts(curl_mimepart *part,
|
||||
curl_mime *subparts, int take_ownership);
|
||||
CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
|
||||
void Curl_mime_initpart(struct curl_mimepart *part, struct Curl_easy *easy);
|
||||
void Curl_mime_cleanpart(struct curl_mimepart *part);
|
||||
CURLcode Curl_mime_duppart(struct curl_mimepart *dst,
|
||||
const curl_mimepart *src);
|
||||
CURLcode Curl_mime_set_subparts(struct curl_mimepart *part,
|
||||
struct curl_mime *subparts,
|
||||
int take_ownership);
|
||||
CURLcode Curl_mime_prepare_headers(struct curl_mimepart *part,
|
||||
const char *contenttype,
|
||||
const char *disposition,
|
||||
enum mimestrategy strategy);
|
||||
curl_off_t Curl_mime_size(curl_mimepart *part);
|
||||
curl_off_t Curl_mime_size(struct curl_mimepart *part);
|
||||
size_t Curl_mime_read(char *buffer, size_t size, size_t nitems,
|
||||
void *instream);
|
||||
CURLcode Curl_mime_rewind(curl_mimepart *part);
|
||||
CURLcode Curl_mime_rewind(struct curl_mimepart *part);
|
||||
const char *Curl_mime_contenttype(const char *filename);
|
||||
void Curl_mime_unpause(curl_mimepart *part);
|
||||
void Curl_mime_unpause(struct curl_mimepart *part);
|
||||
|
||||
#else
|
||||
/* if disabled */
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ enum {
|
|||
FLAGS_FLOATG = 1<<19 /* %g or %G */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct va_stack {
|
||||
FormatType type;
|
||||
int flags;
|
||||
long width; /* width OR width parameter number */
|
||||
|
|
@ -160,7 +160,7 @@ typedef struct {
|
|||
} num;
|
||||
double dnum;
|
||||
} data;
|
||||
} va_stack_t;
|
||||
};
|
||||
|
||||
struct nsprintf {
|
||||
char *buffer;
|
||||
|
|
@ -223,8 +223,8 @@ static bool dprintf_IsQualifierNoDollar(const char *fmt)
|
|||
*
|
||||
******************************************************************/
|
||||
|
||||
static int dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos,
|
||||
va_list arglist)
|
||||
static int dprintf_Pass1(const char *format, struct va_stack *vto,
|
||||
char **endpos, va_list arglist)
|
||||
{
|
||||
char *fmt = (char *)format;
|
||||
int param_num = 0;
|
||||
|
|
@ -570,13 +570,11 @@ static int dprintf_formatf(
|
|||
long param; /* current parameter to read */
|
||||
long param_num = 0; /* parameter counter */
|
||||
|
||||
va_stack_t vto[MAX_PARAMETERS];
|
||||
struct va_stack vto[MAX_PARAMETERS];
|
||||
char *endpos[MAX_PARAMETERS];
|
||||
char **end;
|
||||
|
||||
char work[BUFFSIZE];
|
||||
|
||||
va_stack_t *p;
|
||||
struct va_stack *p;
|
||||
|
||||
/* 'workend' points to the final buffer byte position, but with an extra
|
||||
byte as margin to avoid the (false?) warning Coverity gives us
|
||||
|
|
|
|||
39
lib/nwlib.c
39
lib/nwlib.c
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -36,21 +36,19 @@
|
|||
/* The last #include file should be: */
|
||||
#include "memdebug.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct libthreaddata {
|
||||
int _errno;
|
||||
void *twentybytes;
|
||||
} libthreaddata_t;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct libdata {
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
void *tenbytes;
|
||||
NXKey_t perthreadkey; /* if -1, no key obtained... */
|
||||
NXMutex_t *lock;
|
||||
} libdata_t;
|
||||
};
|
||||
|
||||
int gLibId = -1;
|
||||
void *gLibHandle = (void *) NULL;
|
||||
|
|
@ -60,7 +58,8 @@ NXMutex_t *gLibLock = (NXMutex_t *) NULL;
|
|||
/* internal library function prototypes... */
|
||||
int DisposeLibraryData(void *);
|
||||
void DisposeThreadData(void *);
|
||||
int GetOrSetUpData(int id, libdata_t **data, libthreaddata_t **threaddata);
|
||||
int GetOrSetUpData(int id, struct libdata **data,
|
||||
struct libthreaddata **threaddata);
|
||||
|
||||
|
||||
int _NonAppStart(void *NLMHandle,
|
||||
|
|
@ -154,24 +153,24 @@ int _NonAppCheckUnload(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int GetOrSetUpData(int id, libdata_t **appData,
|
||||
libthreaddata_t **threadData)
|
||||
int GetOrSetUpData(int id, struct libdata **appData,
|
||||
struct libthreaddata **threadData)
|
||||
{
|
||||
int err;
|
||||
libdata_t *app_data;
|
||||
libthreaddata_t *thread_data;
|
||||
struct libdata *app_data;
|
||||
struct libthreaddata *thread_data;
|
||||
NXKey_t key;
|
||||
NX_LOCK_INFO_ALLOC(liblock, "Application Data Lock", 0);
|
||||
|
||||
err = 0;
|
||||
thread_data = (libthreaddata_t *) NULL;
|
||||
thread_data = (struct libthreaddata_t *) NULL;
|
||||
|
||||
/*
|
||||
* Attempt to get our data for the application calling us. This is where we
|
||||
* store whatever application-specific information we need to carry in
|
||||
* support of calling applications.
|
||||
*/
|
||||
app_data = (libdata_t *) get_app_data(id);
|
||||
app_data = (struct libdata *) get_app_data(id);
|
||||
|
||||
if(!app_data) {
|
||||
/*
|
||||
|
|
@ -184,9 +183,9 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||
*/
|
||||
NXLock(gLibLock);
|
||||
|
||||
app_data = (libdata_t *) get_app_data(id);
|
||||
app_data = (struct libdata *) get_app_data(id);
|
||||
if(!app_data) {
|
||||
app_data = calloc(1, sizeof(libdata_t));
|
||||
app_data = calloc(1, sizeof(struct libdata));
|
||||
|
||||
if(app_data) {
|
||||
app_data->tenbytes = malloc(10);
|
||||
|
|
@ -249,7 +248,7 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||
* a pointer is not very important, this just helps to demonstrate that
|
||||
* we can have arbitrarily complex per-thread data.
|
||||
*/
|
||||
thread_data = malloc(sizeof(libthreaddata_t));
|
||||
thread_data = malloc(sizeof(struct libthreaddata));
|
||||
|
||||
if(thread_data) {
|
||||
thread_data->_errno = 0;
|
||||
|
|
@ -257,7 +256,7 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||
|
||||
if(!thread_data->twentybytes) {
|
||||
free(thread_data);
|
||||
thread_data = (libthreaddata_t *) NULL;
|
||||
thread_data = (struct libthreaddata *) NULL;
|
||||
err = ENOMEM;
|
||||
}
|
||||
|
||||
|
|
@ -265,7 +264,7 @@ int GetOrSetUpData(int id, libdata_t **appData,
|
|||
if(err) {
|
||||
free(thread_data->twentybytes);
|
||||
free(thread_data);
|
||||
thread_data = (libthreaddata_t *) NULL;
|
||||
thread_data = (struct libthreaddata *) NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -295,7 +294,7 @@ int DisposeLibraryData(void *data)
|
|||
void DisposeThreadData(void *data)
|
||||
{
|
||||
if(data) {
|
||||
void *twentybytes = ((libthreaddata_t *) data)->twentybytes;
|
||||
void *twentybytes = ((struct libthreaddata *) data)->twentybytes;
|
||||
|
||||
free(twentybytes);
|
||||
free(data);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 2010, Howard Chu, <hyc@openldap.org>
|
||||
* Copyright (C) 2011 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 2011 - 2020, 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
|
||||
|
|
@ -162,10 +162,10 @@ struct ldapconninfo {
|
|||
bool didbind;
|
||||
};
|
||||
|
||||
typedef struct ldapreqinfo {
|
||||
struct ldapreqinfo {
|
||||
int msgid;
|
||||
int nument;
|
||||
} ldapreqinfo;
|
||||
};
|
||||
|
||||
static CURLcode ldap_setup_connection(struct connectdata *conn)
|
||||
{
|
||||
|
|
@ -374,7 +374,7 @@ static CURLcode ldap_disconnect(struct connectdata *conn, bool dead_connection)
|
|||
static CURLcode ldap_do(struct connectdata *conn, bool *done)
|
||||
{
|
||||
struct ldapconninfo *li = conn->proto.ldapc;
|
||||
ldapreqinfo *lr;
|
||||
struct ldapreqinfo *lr;
|
||||
CURLcode status = CURLE_OK;
|
||||
int rc = 0;
|
||||
LDAPURLDesc *ludp = NULL;
|
||||
|
|
@ -406,7 +406,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
|
|||
failf(data, "LDAP local: ldap_search_ext %s", ldap_err2string(rc));
|
||||
return CURLE_LDAP_SEARCH_FAILED;
|
||||
}
|
||||
lr = calloc(1, sizeof(ldapreqinfo));
|
||||
lr = calloc(1, sizeof(struct ldapreqinfo));
|
||||
if(!lr)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
lr->msgid = msgid;
|
||||
|
|
@ -419,7 +419,7 @@ static CURLcode ldap_do(struct connectdata *conn, bool *done)
|
|||
static CURLcode ldap_done(struct connectdata *conn, CURLcode res,
|
||||
bool premature)
|
||||
{
|
||||
ldapreqinfo *lr = conn->data->req.protop;
|
||||
struct ldapreqinfo *lr = conn->data->req.protop;
|
||||
|
||||
(void)res;
|
||||
(void)premature;
|
||||
|
|
@ -443,7 +443,7 @@ static ssize_t ldap_recv(struct connectdata *conn, int sockindex, char *buf,
|
|||
{
|
||||
struct ldapconninfo *li = conn->proto.ldapc;
|
||||
struct Curl_easy *data = conn->data;
|
||||
ldapreqinfo *lr = data->req.protop;
|
||||
struct ldapreqinfo *lr = data->req.protop;
|
||||
int rc, ret;
|
||||
LDAPMessage *msg = NULL;
|
||||
LDAPMessage *ent;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -412,7 +412,7 @@ static CURLcode pop3_perform_apop(struct connectdata *conn)
|
|||
CURLcode result = CURLE_OK;
|
||||
struct pop3_conn *pop3c = &conn->proto.pop3c;
|
||||
size_t i;
|
||||
MD5_context *ctxt;
|
||||
struct MD5_context *ctxt;
|
||||
unsigned char digest[MD5_DIGEST_LEN];
|
||||
char secret[2 * MD5_DIGEST_LEN + 1];
|
||||
|
||||
|
|
|
|||
10
lib/sha256.c
10
lib/sha256.c
|
|
@ -196,10 +196,11 @@ static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
|
|||
|
||||
#include <wincrypt.h>
|
||||
|
||||
typedef struct {
|
||||
struct sha256_ctx {
|
||||
HCRYPTPROV hCryptProv;
|
||||
HCRYPTHASH hHash;
|
||||
} SHA256_CTX;
|
||||
};
|
||||
typedef struct sha256_ctx SHA256_CTX;
|
||||
|
||||
#if !defined(CALG_SHA_256)
|
||||
#define CALG_SHA_256 0x0000800c
|
||||
|
|
@ -280,7 +281,7 @@ do { \
|
|||
} while(0)
|
||||
#endif
|
||||
|
||||
typedef struct sha256_state {
|
||||
struct sha256_state {
|
||||
#ifdef HAVE_LONGLONG
|
||||
unsigned long long length;
|
||||
#else
|
||||
|
|
@ -288,7 +289,8 @@ typedef struct sha256_state {
|
|||
#endif
|
||||
unsigned long state[8], curlen;
|
||||
unsigned char buf[64];
|
||||
} SHA256_CTX;
|
||||
};
|
||||
typedef struct sha256_state SHA256_CTX;
|
||||
|
||||
/* The K array */
|
||||
static const unsigned long K[64] = {
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ CURLcode Curl_SOCKS4(const char *proxy_user,
|
|||
/* FALLTHROUGH */
|
||||
CONNECT_RESOLVED:
|
||||
case CONNECT_RESOLVED: {
|
||||
Curl_addrinfo *hp = NULL;
|
||||
struct Curl_addrinfo *hp = NULL;
|
||||
char buf[64];
|
||||
/*
|
||||
* We cannot use 'hostent' as a struct that Curl_resolv() returns. It
|
||||
|
|
@ -773,7 +773,7 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
|
|||
/* FALLTHROUGH */
|
||||
CONNECT_RESOLVED:
|
||||
case CONNECT_RESOLVED: {
|
||||
Curl_addrinfo *hp = NULL;
|
||||
struct Curl_addrinfo *hp = NULL;
|
||||
if(dns)
|
||||
hp = dns->addr;
|
||||
if(!hp) {
|
||||
|
|
|
|||
68
lib/tftp.c
68
lib/tftp.c
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -115,11 +115,11 @@ typedef enum {
|
|||
TFTP_ERR_NORESPONSE
|
||||
} tftp_error_t;
|
||||
|
||||
typedef struct tftp_packet {
|
||||
struct tftp_packet {
|
||||
unsigned char *data;
|
||||
} tftp_packet_t;
|
||||
};
|
||||
|
||||
typedef struct tftp_state_data {
|
||||
struct tftp_state_data {
|
||||
tftp_state_t state;
|
||||
tftp_mode_t mode;
|
||||
tftp_error_t error;
|
||||
|
|
@ -140,14 +140,14 @@ typedef struct tftp_state_data {
|
|||
int sbytes;
|
||||
int blksize;
|
||||
int requested_blksize;
|
||||
tftp_packet_t rpacket;
|
||||
tftp_packet_t spacket;
|
||||
} tftp_state_data_t;
|
||||
struct tftp_packet rpacket;
|
||||
struct tftp_packet spacket;
|
||||
};
|
||||
|
||||
|
||||
/* Forward declarations */
|
||||
static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event);
|
||||
static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event);
|
||||
static CURLcode tftp_rx(struct tftp_state_data *state, tftp_event_t event);
|
||||
static CURLcode tftp_tx(struct tftp_state_data *state, tftp_event_t event);
|
||||
static CURLcode tftp_connect(struct connectdata *conn, bool *done);
|
||||
static CURLcode tftp_disconnect(struct connectdata *conn,
|
||||
bool dead_connection);
|
||||
|
|
@ -196,7 +196,7 @@ const struct Curl_handler Curl_handler_tftp = {
|
|||
*
|
||||
*
|
||||
**********************************************************/
|
||||
static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
|
||||
static CURLcode tftp_set_timeouts(struct tftp_state_data *state)
|
||||
{
|
||||
time_t maxtime, timeout;
|
||||
timediff_t timeout_ms;
|
||||
|
|
@ -279,25 +279,25 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
|
|||
*
|
||||
**********************************************************/
|
||||
|
||||
static void setpacketevent(tftp_packet_t *packet, unsigned short num)
|
||||
static void setpacketevent(struct tftp_packet *packet, unsigned short num)
|
||||
{
|
||||
packet->data[0] = (unsigned char)(num >> 8);
|
||||
packet->data[1] = (unsigned char)(num & 0xff);
|
||||
}
|
||||
|
||||
|
||||
static void setpacketblock(tftp_packet_t *packet, unsigned short num)
|
||||
static void setpacketblock(struct tftp_packet *packet, unsigned short num)
|
||||
{
|
||||
packet->data[2] = (unsigned char)(num >> 8);
|
||||
packet->data[3] = (unsigned char)(num & 0xff);
|
||||
}
|
||||
|
||||
static unsigned short getrpacketevent(const tftp_packet_t *packet)
|
||||
static unsigned short getrpacketevent(const struct tftp_packet *packet)
|
||||
{
|
||||
return (unsigned short)((packet->data[0] << 8) | packet->data[1]);
|
||||
}
|
||||
|
||||
static unsigned short getrpacketblock(const tftp_packet_t *packet)
|
||||
static unsigned short getrpacketblock(const struct tftp_packet *packet)
|
||||
{
|
||||
return (unsigned short)((packet->data[2] << 8) | packet->data[3]);
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ static const char *tftp_option_get(const char *buf, size_t len,
|
|||
return &buf[loc];
|
||||
}
|
||||
|
||||
static CURLcode tftp_parse_option_ack(tftp_state_data_t *state,
|
||||
static CURLcode tftp_parse_option_ack(struct tftp_state_data *state,
|
||||
const char *ptr, int len)
|
||||
{
|
||||
const char *tmp = ptr;
|
||||
|
|
@ -403,7 +403,7 @@ static CURLcode tftp_parse_option_ack(tftp_state_data_t *state,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static CURLcode tftp_option_add(tftp_state_data_t *state, size_t *csize,
|
||||
static CURLcode tftp_option_add(struct tftp_state_data *state, size_t *csize,
|
||||
char *buf, const char *option)
|
||||
{
|
||||
if(( strlen(option) + *csize + 1) > (size_t)state->blksize)
|
||||
|
|
@ -413,7 +413,7 @@ static CURLcode tftp_option_add(tftp_state_data_t *state, size_t *csize,
|
|||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static CURLcode tftp_connect_for_tx(tftp_state_data_t *state,
|
||||
static CURLcode tftp_connect_for_tx(struct tftp_state_data *state,
|
||||
tftp_event_t event)
|
||||
{
|
||||
CURLcode result;
|
||||
|
|
@ -429,7 +429,7 @@ static CURLcode tftp_connect_for_tx(tftp_state_data_t *state,
|
|||
return tftp_tx(state, event);
|
||||
}
|
||||
|
||||
static CURLcode tftp_connect_for_rx(tftp_state_data_t *state,
|
||||
static CURLcode tftp_connect_for_rx(struct tftp_state_data *state,
|
||||
tftp_event_t event)
|
||||
{
|
||||
CURLcode result;
|
||||
|
|
@ -445,7 +445,8 @@ static CURLcode tftp_connect_for_rx(tftp_state_data_t *state,
|
|||
return tftp_rx(state, event);
|
||||
}
|
||||
|
||||
static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
|
||||
static CURLcode tftp_send_first(struct tftp_state_data *state,
|
||||
tftp_event_t event)
|
||||
{
|
||||
size_t sbytes;
|
||||
ssize_t senddata;
|
||||
|
|
@ -598,7 +599,8 @@ static CURLcode tftp_send_first(tftp_state_data_t *state, tftp_event_t event)
|
|||
* Event handler for the RX state
|
||||
*
|
||||
**********************************************************/
|
||||
static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
|
||||
static CURLcode tftp_rx(struct tftp_state_data *state,
|
||||
tftp_event_t event)
|
||||
{
|
||||
ssize_t sbytes;
|
||||
int rblock;
|
||||
|
|
@ -720,7 +722,7 @@ static CURLcode tftp_rx(tftp_state_data_t *state, tftp_event_t event)
|
|||
* Event handler for the TX state
|
||||
*
|
||||
**********************************************************/
|
||||
static CURLcode tftp_tx(tftp_state_data_t *state, tftp_event_t event)
|
||||
static CURLcode tftp_tx(struct tftp_state_data *state, tftp_event_t event)
|
||||
{
|
||||
struct Curl_easy *data = state->conn->data;
|
||||
ssize_t sbytes;
|
||||
|
|
@ -920,7 +922,7 @@ static CURLcode tftp_translate_code(tftp_error_t error)
|
|||
* The tftp state machine event dispatcher
|
||||
*
|
||||
**********************************************************/
|
||||
static CURLcode tftp_state_machine(tftp_state_data_t *state,
|
||||
static CURLcode tftp_state_machine(struct tftp_state_data *state,
|
||||
tftp_event_t event)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
|
|
@ -961,7 +963,7 @@ static CURLcode tftp_state_machine(tftp_state_data_t *state,
|
|||
**********************************************************/
|
||||
static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection)
|
||||
{
|
||||
tftp_state_data_t *state = conn->proto.tftpc;
|
||||
struct tftp_state_data *state = conn->proto.tftpc;
|
||||
(void) dead_connection;
|
||||
|
||||
/* done, free dynamically allocated pkt buffers */
|
||||
|
|
@ -983,13 +985,13 @@ static CURLcode tftp_disconnect(struct connectdata *conn, bool dead_connection)
|
|||
**********************************************************/
|
||||
static CURLcode tftp_connect(struct connectdata *conn, bool *done)
|
||||
{
|
||||
tftp_state_data_t *state;
|
||||
struct tftp_state_data *state;
|
||||
int blksize;
|
||||
int need_blksize;
|
||||
|
||||
blksize = TFTP_BLKSIZE_DEFAULT;
|
||||
|
||||
state = conn->proto.tftpc = calloc(1, sizeof(tftp_state_data_t));
|
||||
state = conn->proto.tftpc = calloc(1, sizeof(struct tftp_state_data));
|
||||
if(!state)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
|
||||
|
|
@ -1078,7 +1080,7 @@ static CURLcode tftp_done(struct connectdata *conn, CURLcode status,
|
|||
bool premature)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
tftp_state_data_t *state = (tftp_state_data_t *)conn->proto.tftpc;
|
||||
struct tftp_state_data *state = conn->proto.tftpc;
|
||||
|
||||
(void)status; /* unused */
|
||||
(void)premature; /* not used */
|
||||
|
|
@ -1119,7 +1121,7 @@ static CURLcode tftp_receive_packet(struct connectdata *conn)
|
|||
curl_socklen_t fromlen;
|
||||
CURLcode result = CURLE_OK;
|
||||
struct Curl_easy *data = conn->data;
|
||||
tftp_state_data_t *state = (tftp_state_data_t *)conn->proto.tftpc;
|
||||
struct tftp_state_data *state = conn->proto.tftpc;
|
||||
struct SingleRequest *k = &data->req;
|
||||
|
||||
/* Receive the packet */
|
||||
|
|
@ -1206,8 +1208,8 @@ static CURLcode tftp_receive_packet(struct connectdata *conn)
|
|||
**********************************************************/
|
||||
static long tftp_state_timeout(struct connectdata *conn, tftp_event_t *event)
|
||||
{
|
||||
time_t current;
|
||||
tftp_state_data_t *state = (tftp_state_data_t *)conn->proto.tftpc;
|
||||
time_t current;
|
||||
struct tftp_state_data *state = conn->proto.tftpc;
|
||||
|
||||
if(event)
|
||||
*event = TFTP_EVENT_NONE;
|
||||
|
|
@ -1244,7 +1246,7 @@ static CURLcode tftp_multi_statemach(struct connectdata *conn, bool *done)
|
|||
tftp_event_t event;
|
||||
CURLcode result = CURLE_OK;
|
||||
struct Curl_easy *data = conn->data;
|
||||
tftp_state_data_t *state = (tftp_state_data_t *)conn->proto.tftpc;
|
||||
struct tftp_state_data *state = conn->proto.tftpc;
|
||||
long timeout_ms = tftp_state_timeout(conn, &event);
|
||||
|
||||
*done = FALSE;
|
||||
|
|
@ -1328,7 +1330,7 @@ static CURLcode tftp_doing(struct connectdata *conn, bool *dophase_done)
|
|||
static CURLcode tftp_perform(struct connectdata *conn, bool *dophase_done)
|
||||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
tftp_state_data_t *state = (tftp_state_data_t *)conn->proto.tftpc;
|
||||
struct tftp_state_data *state = conn->proto.tftpc;
|
||||
|
||||
*dophase_done = FALSE;
|
||||
|
||||
|
|
@ -1358,7 +1360,7 @@ static CURLcode tftp_perform(struct connectdata *conn, bool *dophase_done)
|
|||
|
||||
static CURLcode tftp_do(struct connectdata *conn, bool *done)
|
||||
{
|
||||
tftp_state_data_t *state;
|
||||
struct tftp_state_data *state;
|
||||
CURLcode result;
|
||||
|
||||
*done = FALSE;
|
||||
|
|
@ -1369,7 +1371,7 @@ static CURLcode tftp_do(struct connectdata *conn, bool *done)
|
|||
return result;
|
||||
}
|
||||
|
||||
state = (tftp_state_data_t *)conn->proto.tftpc;
|
||||
state = conn->proto.tftpc;
|
||||
if(!state)
|
||||
return CURLE_TFTP_ILLEGAL;
|
||||
|
||||
|
|
|
|||
|
|
@ -613,8 +613,8 @@ struct SingleRequest {
|
|||
enum expect100 exp100; /* expect 100 continue state */
|
||||
enum upgrade101 upgr101; /* 101 upgrade state */
|
||||
|
||||
struct contenc_writer_s *writer_stack; /* Content unencoding stack. */
|
||||
/* See sec 3.5, RFC2616. */
|
||||
/* Content unencoding stack. See sec 3.5, RFC2616. */
|
||||
struct contenc_writer *writer_stack;
|
||||
time_t timeofdoc;
|
||||
long bodywrites;
|
||||
char *buf;
|
||||
|
|
@ -875,8 +875,8 @@ struct connectdata {
|
|||
/* 'ip_addr' is the particular IP we connected to. It points to a struct
|
||||
within the DNS cache, so this pointer is only valid as long as the DNS
|
||||
cache entry remains locked. It gets unlocked in Curl_done() */
|
||||
Curl_addrinfo *ip_addr;
|
||||
Curl_addrinfo *tempaddr[2]; /* for happy eyeballs */
|
||||
struct Curl_addrinfo *ip_addr;
|
||||
struct Curl_addrinfo *tempaddr[2]; /* for happy eyeballs */
|
||||
|
||||
/* 'ip_addr_str' is the ip_addr data as a human readable string.
|
||||
It remains available as long as the connection does, which is longer than
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -96,7 +96,7 @@ CURLcode Curl_auth_create_cram_md5_message(struct Curl_easy *data,
|
|||
{
|
||||
CURLcode result = CURLE_OK;
|
||||
size_t chlglen = 0;
|
||||
HMAC_context *ctxt;
|
||||
struct HMAC_context *ctxt;
|
||||
unsigned char digest[MD5_DIGEST_LEN];
|
||||
char *response;
|
||||
|
||||
|
|
|
|||
|
|
@ -358,7 +358,7 @@ CURLcode Curl_auth_create_digest_md5_message(struct Curl_easy *data,
|
|||
char **outptr, size_t *outlen)
|
||||
{
|
||||
size_t i;
|
||||
MD5_context *ctxt;
|
||||
struct MD5_context *ctxt;
|
||||
char *response = NULL;
|
||||
unsigned char digest[MD5_DIGEST_LEN];
|
||||
char HA1_hex[2 * MD5_DIGEST_LEN + 1];
|
||||
|
|
|
|||
|
|
@ -108,13 +108,13 @@ struct ssl_backend_data {
|
|||
#define BACKEND connssl->backend
|
||||
|
||||
/* Supported ciphers. */
|
||||
typedef struct {
|
||||
struct gskit_cipher {
|
||||
const char *name; /* Cipher name. */
|
||||
const char *gsktoken; /* Corresponding token for GSKit String. */
|
||||
unsigned int versions; /* SSL version flags. */
|
||||
} gskit_cipher;
|
||||
};
|
||||
|
||||
static const gskit_cipher ciphertable[] = {
|
||||
static const struct gskit_cipher ciphertable[] = {
|
||||
{ "null-md5", "01",
|
||||
CURL_GSKPROTO_SSLV3_MASK | CURL_GSKPROTO_TLSV10_MASK |
|
||||
CURL_GSKPROTO_TLSV11_MASK | CURL_GSKPROTO_TLSV12_MASK },
|
||||
|
|
@ -307,7 +307,7 @@ static CURLcode set_ciphers(struct connectdata *conn,
|
|||
struct Curl_easy *data = conn->data;
|
||||
const char *cipherlist = SSL_CONN_CONFIG(cipher_list);
|
||||
const char *clp;
|
||||
const gskit_cipher *ctp;
|
||||
const struct gskit_cipher *ctp;
|
||||
int i;
|
||||
int l;
|
||||
bool unsupported;
|
||||
|
|
|
|||
|
|
@ -101,10 +101,10 @@ struct ptr_list_wrap {
|
|||
struct curl_llist_element node;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct cipher_s {
|
||||
const char *name;
|
||||
int num;
|
||||
} cipher_s;
|
||||
};
|
||||
|
||||
#define PK11_SETATTRS(_attr, _idx, _type, _val, _len) do { \
|
||||
CK_ATTRIBUTE *ptr = (_attr) + ((_idx)++); \
|
||||
|
|
@ -116,7 +116,7 @@ typedef struct {
|
|||
#define CERT_NewTempCertificate __CERT_NewTempCertificate
|
||||
|
||||
#define NUM_OF_CIPHERS sizeof(cipherlist)/sizeof(cipherlist[0])
|
||||
static const cipher_s cipherlist[] = {
|
||||
static const struct cipher_s cipherlist[] = {
|
||||
/* SSL2 cipher suites */
|
||||
{"rc4", SSL_EN_RC4_128_WITH_MD5},
|
||||
{"rc4-md5", SSL_EN_RC4_128_WITH_MD5},
|
||||
|
|
|
|||
|
|
@ -215,11 +215,11 @@
|
|||
#define ENABLE_SSLKEYLOGFILE
|
||||
|
||||
#ifdef ENABLE_SSLKEYLOGFILE
|
||||
typedef struct ssl_tap_state {
|
||||
struct ssl_tap_state {
|
||||
int master_key_length;
|
||||
unsigned char master_key[SSL_MAX_MASTER_KEY_LENGTH];
|
||||
unsigned char client_random[SSL3_RANDOM_SIZE];
|
||||
} ssl_tap_state_t;
|
||||
};
|
||||
#endif /* ENABLE_SSLKEYLOGFILE */
|
||||
|
||||
struct ssl_backend_data {
|
||||
|
|
@ -229,7 +229,7 @@ struct ssl_backend_data {
|
|||
X509* server_cert;
|
||||
#ifdef ENABLE_SSLKEYLOGFILE
|
||||
/* tap_state holds the last seen master key if we're logging them */
|
||||
ssl_tap_state_t tap_state;
|
||||
struct ssl_tap_state tap_state;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ static void ossl_keylog_callback(const SSL *ssl, const char *line)
|
|||
* tap_ssl_key is called by libcurl to make the CLIENT_RANDOMs if the OpenSSL
|
||||
* being used doesn't have native support for doing that.
|
||||
*/
|
||||
static void tap_ssl_key(const SSL *ssl, ssl_tap_state_t *state)
|
||||
static void tap_ssl_key(const SSL *ssl, struct ssl_tap_state *state)
|
||||
{
|
||||
const char *hex = "0123456789ABCDEF";
|
||||
int pos, i;
|
||||
|
|
|
|||
|
|
@ -2243,8 +2243,8 @@ static CURLcode pkp_pin_peer_pubkey(struct connectdata *conn, int sockindex,
|
|||
SECURITY_STATUS sspi_status;
|
||||
const char *x509_der;
|
||||
DWORD x509_der_len;
|
||||
curl_X509certificate x509_parsed;
|
||||
curl_asn1Element *pubkey;
|
||||
struct Curl_X509certificate x509_parsed;
|
||||
struct Curl_asn1Element *pubkey;
|
||||
|
||||
sspi_status =
|
||||
s_pSecFn->QueryContextAttributes(&BACKEND->ctxt->ctxt_handle,
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
#define BEGIN_CERT "-----BEGIN CERTIFICATE-----"
|
||||
#define END_CERT "\n-----END CERTIFICATE-----"
|
||||
|
||||
typedef struct {
|
||||
struct cert_chain_engine_config_win7 {
|
||||
DWORD cbSize;
|
||||
HCERTSTORE hRestrictedRoot;
|
||||
HCERTSTORE hRestrictedTrust;
|
||||
|
|
@ -70,7 +70,7 @@ typedef struct {
|
|||
DWORD CycleDetectionModulus;
|
||||
HCERTSTORE hExclusiveRoot;
|
||||
HCERTSTORE hExclusiveTrustedPeople;
|
||||
} CERT_CHAIN_ENGINE_CONFIG_WIN7, *PCERT_CHAIN_ENGINE_CONFIG_WIN7;
|
||||
};
|
||||
|
||||
static int is_cr_or_lf(char c)
|
||||
{
|
||||
|
|
@ -585,7 +585,7 @@ CURLcode Curl_verify_certificate(struct connectdata *conn, int sockindex)
|
|||
}
|
||||
|
||||
if(result == CURLE_OK) {
|
||||
CERT_CHAIN_ENGINE_CONFIG_WIN7 engine_config;
|
||||
struct cert_chain_engine_config_win7 engine_config;
|
||||
BOOL create_engine_result;
|
||||
|
||||
memset(&engine_config, 0, sizeof(engine_config));
|
||||
|
|
|
|||
|
|
@ -1084,7 +1084,7 @@ bool Curl_none_false_start(void)
|
|||
CURLcode Curl_none_md5sum(unsigned char *input, size_t inputlen,
|
||||
unsigned char *md5sum, size_t md5len UNUSED_PARAM)
|
||||
{
|
||||
MD5_context *MD5pw;
|
||||
struct MD5_context *MD5pw;
|
||||
|
||||
(void)md5len;
|
||||
|
||||
|
|
|
|||
|
|
@ -511,8 +511,8 @@ wolfssl_connect_step2(struct connectdata *conn,
|
|||
X509 *x509;
|
||||
const char *x509_der;
|
||||
int x509_der_len;
|
||||
curl_X509certificate x509_parsed;
|
||||
curl_asn1Element *pubkey;
|
||||
struct Curl_X509certificate x509_parsed;
|
||||
struct Curl_asn1Element *pubkey;
|
||||
CURLcode result;
|
||||
|
||||
x509 = SSL_get_peer_certificate(backend->handle);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
static const char cnOID[] = "2.5.4.3"; /* Common name. */
|
||||
static const char sanOID[] = "2.5.29.17"; /* Subject alternative name. */
|
||||
|
||||
static const curl_OID OIDtable[] = {
|
||||
static const struct Curl_OID OIDtable[] = {
|
||||
{ "1.2.840.10040.4.1", "dsa" },
|
||||
{ "1.2.840.10040.4.3", "dsa-with-sha1" },
|
||||
{ "1.2.840.10045.2.1", "ecPublicKey" },
|
||||
|
|
@ -103,16 +103,16 @@ static const curl_OID OIDtable[] = {
|
|||
* Please note there is no pretention here to rewrite a full SSL library.
|
||||
*/
|
||||
|
||||
static const char *getASN1Element(curl_asn1Element *elem,
|
||||
static const char *getASN1Element(struct Curl_asn1Element *elem,
|
||||
const char *beg, const char *end)
|
||||
WARN_UNUSED_RESULT;
|
||||
|
||||
static const char *getASN1Element(curl_asn1Element *elem,
|
||||
static const char *getASN1Element(struct Curl_asn1Element *elem,
|
||||
const char *beg, const char *end)
|
||||
{
|
||||
unsigned char b;
|
||||
unsigned long len;
|
||||
curl_asn1Element lelem;
|
||||
struct Curl_asn1Element lelem;
|
||||
|
||||
/* Get a single ASN.1 element into `elem', parse ASN.1 string at `beg'
|
||||
ending at `end'.
|
||||
|
|
@ -176,9 +176,9 @@ static const char *getASN1Element(curl_asn1Element *elem,
|
|||
* Search the null terminated OID or OID identifier in local table.
|
||||
* Return the table entry pointer or NULL if not found.
|
||||
*/
|
||||
static const curl_OID *searchOID(const char *oid)
|
||||
static const struct Curl_OID *searchOID(const char *oid)
|
||||
{
|
||||
const curl_OID *op;
|
||||
const struct Curl_OID *op;
|
||||
for(op = OIDtable; op->numoid; op++)
|
||||
if(!strcmp(op->numoid, oid) || strcasecompare(op->textoid, oid))
|
||||
return op;
|
||||
|
|
@ -445,7 +445,7 @@ static const char *OID2str(const char *beg, const char *end, bool symbolic)
|
|||
buf[buflen] = '\0';
|
||||
|
||||
if(symbolic) {
|
||||
const curl_OID *op = searchOID(buf);
|
||||
const struct Curl_OID *op = searchOID(buf);
|
||||
if(op) {
|
||||
free(buf);
|
||||
buf = strdup(op->textoid);
|
||||
|
|
@ -565,7 +565,7 @@ static const char *UTime2str(const char *beg, const char *end)
|
|||
* Convert an ASN.1 element to a printable string.
|
||||
* Return the dynamically allocated string, or NULL if an error occurs.
|
||||
*/
|
||||
static const char *ASN1tostr(curl_asn1Element *elem, int type)
|
||||
static const char *ASN1tostr(struct Curl_asn1Element *elem, int type)
|
||||
{
|
||||
if(elem->constructed)
|
||||
return NULL; /* No conversion of structured elements. */
|
||||
|
|
@ -609,12 +609,12 @@ static const char *ASN1tostr(curl_asn1Element *elem, int type)
|
|||
* ASCII encode distinguished name at `dn' into the `buflen'-sized buffer at
|
||||
* `buf'. Return the total string length, even if larger than `buflen'.
|
||||
*/
|
||||
static ssize_t encodeDN(char *buf, size_t buflen, curl_asn1Element *dn)
|
||||
static ssize_t encodeDN(char *buf, size_t buflen, struct Curl_asn1Element *dn)
|
||||
{
|
||||
curl_asn1Element rdn;
|
||||
curl_asn1Element atv;
|
||||
curl_asn1Element oid;
|
||||
curl_asn1Element value;
|
||||
struct Curl_asn1Element rdn;
|
||||
struct Curl_asn1Element atv;
|
||||
struct Curl_asn1Element oid;
|
||||
struct Curl_asn1Element value;
|
||||
size_t l = 0;
|
||||
const char *p1;
|
||||
const char *p2;
|
||||
|
|
@ -683,7 +683,7 @@ static ssize_t encodeDN(char *buf, size_t buflen, curl_asn1Element *dn)
|
|||
* Convert an ASN.1 distinguished name into a printable string.
|
||||
* Return the dynamically allocated string, or NULL if an error occurs.
|
||||
*/
|
||||
static const char *DNtostr(curl_asn1Element *dn)
|
||||
static const char *DNtostr(struct Curl_asn1Element *dn)
|
||||
{
|
||||
char *buf = NULL;
|
||||
ssize_t buflen = encodeDN(NULL, 0, dn);
|
||||
|
|
@ -703,11 +703,11 @@ static const char *DNtostr(curl_asn1Element *dn)
|
|||
* Syntax is assumed to have already been checked by the SSL backend.
|
||||
* See RFC 5280.
|
||||
*/
|
||||
int Curl_parseX509(curl_X509certificate *cert,
|
||||
int Curl_parseX509(struct Curl_X509certificate *cert,
|
||||
const char *beg, const char *end)
|
||||
{
|
||||
curl_asn1Element elem;
|
||||
curl_asn1Element tbsCertificate;
|
||||
struct Curl_asn1Element elem;
|
||||
struct Curl_asn1Element tbsCertificate;
|
||||
const char *ccp;
|
||||
static const char defaultVersion = 0; /* v1. */
|
||||
|
||||
|
|
@ -835,10 +835,10 @@ static size_t copySubstring(char *to, const char *from)
|
|||
return i;
|
||||
}
|
||||
|
||||
static const char *dumpAlgo(curl_asn1Element *param,
|
||||
static const char *dumpAlgo(struct Curl_asn1Element *param,
|
||||
const char *beg, const char *end)
|
||||
{
|
||||
curl_asn1Element oid;
|
||||
struct Curl_asn1Element oid;
|
||||
|
||||
/* Get algorithm parameters and return algorithm name. */
|
||||
|
||||
|
|
@ -855,7 +855,7 @@ static const char *dumpAlgo(curl_asn1Element *param,
|
|||
}
|
||||
|
||||
static void do_pubkey_field(struct Curl_easy *data, int certnum,
|
||||
const char *label, curl_asn1Element *elem)
|
||||
const char *label, struct Curl_asn1Element *elem)
|
||||
{
|
||||
const char *output;
|
||||
|
||||
|
|
@ -872,11 +872,11 @@ static void do_pubkey_field(struct Curl_easy *data, int certnum,
|
|||
}
|
||||
|
||||
static void do_pubkey(struct Curl_easy *data, int certnum,
|
||||
const char *algo, curl_asn1Element *param,
|
||||
curl_asn1Element *pubkey)
|
||||
const char *algo, struct Curl_asn1Element *param,
|
||||
struct Curl_asn1Element *pubkey)
|
||||
{
|
||||
curl_asn1Element elem;
|
||||
curl_asn1Element pk;
|
||||
struct Curl_asn1Element elem;
|
||||
struct Curl_asn1Element pk;
|
||||
const char *p;
|
||||
|
||||
/* Generate all information records for the public key. */
|
||||
|
|
@ -950,9 +950,9 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
|
|||
const char *beg,
|
||||
const char *end)
|
||||
{
|
||||
curl_X509certificate cert;
|
||||
struct Curl_X509certificate cert;
|
||||
struct Curl_easy *data = conn->data;
|
||||
curl_asn1Element param;
|
||||
struct Curl_asn1Element param;
|
||||
const char *ccp;
|
||||
char *cp1;
|
||||
size_t cl1;
|
||||
|
|
@ -1111,7 +1111,7 @@ CURLcode Curl_extract_certinfo(struct connectdata *conn,
|
|||
static const char *checkOID(const char *beg, const char *end,
|
||||
const char *oid)
|
||||
{
|
||||
curl_asn1Element e;
|
||||
struct Curl_asn1Element e;
|
||||
const char *ccp;
|
||||
const char *p;
|
||||
bool matched;
|
||||
|
|
@ -1136,22 +1136,21 @@ CURLcode Curl_verifyhost(struct connectdata *conn,
|
|||
const char *beg, const char *end)
|
||||
{
|
||||
struct Curl_easy *data = conn->data;
|
||||
curl_X509certificate cert;
|
||||
curl_asn1Element dn;
|
||||
curl_asn1Element elem;
|
||||
curl_asn1Element ext;
|
||||
curl_asn1Element name;
|
||||
struct Curl_X509certificate cert;
|
||||
struct Curl_asn1Element dn;
|
||||
struct Curl_asn1Element elem;
|
||||
struct Curl_asn1Element ext;
|
||||
struct Curl_asn1Element name;
|
||||
const char *p;
|
||||
const char *q;
|
||||
char *dnsname;
|
||||
int matched = -1;
|
||||
size_t addrlen = (size_t) -1;
|
||||
ssize_t len;
|
||||
const char * const hostname = SSL_IS_PROXY()? conn->http_proxy.host.name:
|
||||
conn->host.name;
|
||||
const char * const dispname = SSL_IS_PROXY()?
|
||||
conn->http_proxy.host.dispname:
|
||||
conn->host.dispname;
|
||||
const char *const hostname = SSL_IS_PROXY()?
|
||||
conn->http_proxy.host.name : conn->host.name;
|
||||
const char *const dispname = SSL_IS_PROXY()?
|
||||
conn->http_proxy.host.dispname : conn->host.dispname;
|
||||
#ifdef ENABLE_IPV6
|
||||
struct in6_addr addr;
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2020, 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
|
||||
|
|
@ -79,52 +79,51 @@
|
|||
*/
|
||||
|
||||
/* ASN.1 parsed element. */
|
||||
typedef struct {
|
||||
const char * header; /* Pointer to header byte. */
|
||||
const char * beg; /* Pointer to element data. */
|
||||
const char * end; /* Pointer to 1st byte after element. */
|
||||
unsigned char class; /* ASN.1 element class. */
|
||||
unsigned char tag; /* ASN.1 element tag. */
|
||||
bool constructed; /* Element is constructed. */
|
||||
} curl_asn1Element;
|
||||
struct Curl_asn1Element {
|
||||
const char *header; /* Pointer to header byte. */
|
||||
const char *beg; /* Pointer to element data. */
|
||||
const char *end; /* Pointer to 1st byte after element. */
|
||||
unsigned char class; /* ASN.1 element class. */
|
||||
unsigned char tag; /* ASN.1 element tag. */
|
||||
bool constructed; /* Element is constructed. */
|
||||
};
|
||||
|
||||
|
||||
/* ASN.1 OID table entry. */
|
||||
typedef struct {
|
||||
const char * numoid; /* Dotted-numeric OID. */
|
||||
const char * textoid; /* OID name. */
|
||||
} curl_OID;
|
||||
struct Curl_OID {
|
||||
const char *numoid; /* Dotted-numeric OID. */
|
||||
const char *textoid; /* OID name. */
|
||||
};
|
||||
|
||||
|
||||
/* X509 certificate: RFC 5280. */
|
||||
typedef struct {
|
||||
curl_asn1Element certificate;
|
||||
curl_asn1Element version;
|
||||
curl_asn1Element serialNumber;
|
||||
curl_asn1Element signatureAlgorithm;
|
||||
curl_asn1Element signature;
|
||||
curl_asn1Element issuer;
|
||||
curl_asn1Element notBefore;
|
||||
curl_asn1Element notAfter;
|
||||
curl_asn1Element subject;
|
||||
curl_asn1Element subjectPublicKeyInfo;
|
||||
curl_asn1Element subjectPublicKeyAlgorithm;
|
||||
curl_asn1Element subjectPublicKey;
|
||||
curl_asn1Element issuerUniqueID;
|
||||
curl_asn1Element subjectUniqueID;
|
||||
curl_asn1Element extensions;
|
||||
} curl_X509certificate;
|
||||
|
||||
struct Curl_X509certificate {
|
||||
struct Curl_asn1Element certificate;
|
||||
struct Curl_asn1Element version;
|
||||
struct Curl_asn1Element serialNumber;
|
||||
struct Curl_asn1Element signatureAlgorithm;
|
||||
struct Curl_asn1Element signature;
|
||||
struct Curl_asn1Element issuer;
|
||||
struct Curl_asn1Element notBefore;
|
||||
struct Curl_asn1Element notAfter;
|
||||
struct Curl_asn1Element subject;
|
||||
struct Curl_asn1Element subjectPublicKeyInfo;
|
||||
struct Curl_asn1Element subjectPublicKeyAlgorithm;
|
||||
struct Curl_asn1Element subjectPublicKey;
|
||||
struct Curl_asn1Element issuerUniqueID;
|
||||
struct Curl_asn1Element subjectUniqueID;
|
||||
struct Curl_asn1Element extensions;
|
||||
};
|
||||
|
||||
/*
|
||||
* Prototypes.
|
||||
*/
|
||||
|
||||
const char *Curl_getASN1Element(curl_asn1Element *elem,
|
||||
const char *beg, const char *end);
|
||||
const char *Curl_ASN1tostr(curl_asn1Element *elem, int type);
|
||||
const char *Curl_DNtostr(curl_asn1Element *dn);
|
||||
int Curl_parseX509(curl_X509certificate *cert,
|
||||
const char *Curl_getASN1Element(struct Curl_asn1Element *elem,
|
||||
const char *beg, const char *end);
|
||||
const char *Curl_ASN1tostr(struct Curl_asn1Element *elem, int type);
|
||||
const char *Curl_DNtostr(struct Curl_asn1Element *dn);
|
||||
int Curl_parseX509(struct Curl_X509certificate *cert,
|
||||
const char *beg, const char *end);
|
||||
CURLcode Curl_extract_certinfo(struct connectdata *conn, int certnum,
|
||||
const char *beg, const char *end);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue