]> git.proxmox.com Git - libgit2.git/commitdiff
git_cert: child types use proper base type
authorEdward Thomson <ethomson@edwardthomson.com>
Mon, 29 Jun 2015 22:51:18 +0000 (22:51 +0000)
committerEdward Thomson <ethomson@edwardthomson.com>
Fri, 10 Jul 2015 14:28:33 +0000 (09:28 -0500)
CHANGELOG.md
include/git2/transport.h
src/curl_stream.c
src/openssl_stream.c
src/stransport_stream.c
src/transports/ssh.c
src/transports/winhttp.c

index 0aae4da6a18b92df1e2fa14ac3c932d21a213734..fa659919053ddd59c29ee354cf1e4a26219187e4 100644 (file)
@@ -7,6 +7,10 @@ v0.23 + 1
 
 ### API removals
 
+### Breaking API changes
+
+* `git_cert` descendent types now have a proper `parent` member
+
 v0.23
 ------
 
index 2eeebd565891804f81a7ca6d23e1121ca22a1f03..fd55eac0ab08132e7ee5848e23e67bd6e1c634e5 100644 (file)
@@ -37,39 +37,32 @@ typedef enum {
  * Hostkey information taken from libssh2
  */
 typedef struct {
+       git_cert parent;
+
        /**
-        * Type of certificate. Here to share the header with
-        * `git_cert`.
+        * A hostkey type from libssh2, either
+        * `GIT_CERT_SSH_MD5` or `GIT_CERT_SSH_SHA1`
         */
-       git_cert_t cert_type;
-        /**
-         * A hostkey type from libssh2, either
-         * `GIT_CERT_SSH_MD5` or `GIT_CERT_SSH_SHA1`
-         */
        git_cert_ssh_t type;
 
-        /**
-         * Hostkey hash. If type has `GIT_CERT_SSH_MD5` set, this will
-         * have the MD5 hash of the hostkey.
-         */
+       /**
+        * Hostkey hash. If type has `GIT_CERT_SSH_MD5` set, this will
+        * have the MD5 hash of the hostkey.
+        */
        unsigned char hash_md5[16];
 
-        /**
-         * Hostkey hash. If type has `GIT_CERT_SSH_SHA1` set, this will
-         * have the SHA-1 hash of the hostkey.
-         */
-        unsigned char hash_sha1[20];
+       /**
+        * Hostkey hash. If type has `GIT_CERT_SSH_SHA1` set, this will
+        * have the SHA-1 hash of the hostkey.
+        */
+       unsigned char hash_sha1[20];
 } git_cert_hostkey;
 
 /**
  * X.509 certificate information
  */
 typedef struct {
-       /**
-        * Type of certificate. Here to share the header with
-        * `git_cert`.
-        */
-       git_cert_t cert_type;
+       git_cert parent;
        /**
         * Pointer to the X.509 certificate data
         */
index 6534bdbbe78707c7e714130db06a796457291d76..63421fcf7a81fd8fa13fa01afae613945dcfe054 100644 (file)
@@ -67,9 +67,9 @@ static int curls_certificate(git_cert **out, git_stream *stream)
 
        /* No information is available, can happen with SecureTransport */
        if (certinfo->num_of_certs == 0) {
-               s->cert_info.cert_type = GIT_CERT_NONE;
-               s->cert_info.data      = NULL;
-               s->cert_info.len       = 0;
+               s->cert_info.parent.cert_type = GIT_CERT_NONE;
+               s->cert_info.data             = NULL;
+               s->cert_info.len              = 0;
                return 0;
        }
 
@@ -85,11 +85,11 @@ static int curls_certificate(git_cert **out, git_stream *stream)
        s->cert_info_strings.strings = (char **) strings.contents;
        s->cert_info_strings.count   = strings.length;
 
-       s->cert_info.cert_type = GIT_CERT_STRARRAY;
-       s->cert_info.data      = &s->cert_info_strings;
-       s->cert_info.len       = strings.length;
+       s->cert_info.parent.cert_type = GIT_CERT_STRARRAY;
+       s->cert_info.data             = &s->cert_info_strings;
+       s->cert_info.len              = strings.length;
 
-       *out = (git_cert *) &s->cert_info;
+       *out = &s->cert_info.parent;
 
        return 0;
 }
index 958252e9f66951f74449efa654d15e5a7aacf111..1bd4f1421c0e9697066d71566d995a4610cc607e 100644 (file)
@@ -358,11 +358,12 @@ int openssl_certificate(git_cert **out, git_stream *stream)
                return -1;
        }
 
-       st->cert_info.cert_type = GIT_CERT_X509;
+       st->cert_info.parent.cert_type = GIT_CERT_X509;
        st->cert_info.data = encoded_cert;
        st->cert_info.len = len;
 
-       *out = (git_cert *)&st->cert_info;
+       *out = &st->cert_info.parent;
+
        return 0;
 }
 
index 10e19166cd34aa1d25667d49561e1474baff9cce..33b6c5c384c6e6f4bb760f719bd3e809dca4a282 100644 (file)
@@ -108,7 +108,7 @@ int stransport_certificate(git_cert **out, git_stream *stream)
                return -1;
        }
 
-       st->cert_info.cert_type = GIT_CERT_X509;
+       st->cert_info.parent.cert_type = GIT_CERT_X509;
        st->cert_info.data = (void *) CFDataGetBytePtr(st->der_data);
        st->cert_info.len = CFDataGetLength(st->der_data);
 
index 83af137f8b9aa6d74165410693a3f3d3a09d6912..0b0d4bac3602d36993181082261bc257b79b985d 100644 (file)
@@ -525,10 +525,10 @@ static int _git_ssh_setup_conn(
                goto done;
 
        if (t->owner->certificate_check_cb != NULL) {
-               git_cert_hostkey cert = { 0 }, *cert_ptr;
+               git_cert_hostkey cert = {{ 0 }}, *cert_ptr;
                const char *key;
 
-               cert.cert_type = GIT_CERT_HOSTKEY_LIBSSH2;
+               cert.parent.cert_type = GIT_CERT_HOSTKEY_LIBSSH2;
 
                key = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_SHA1);
                if (key != NULL) {
index da047d690c7e8ddb95d97e65e29a7bcff6481cff..0c43c4b0b9a9eaff2ad77ede600ee705ed41ab54 100644 (file)
@@ -228,7 +228,7 @@ static int certificate_check(winhttp_stream *s, int valid)
        }
 
        giterr_clear();
-       cert.cert_type = GIT_CERT_X509;
+       cert.parent.cert_type = GIT_CERT_X509;
        cert.data = cert_ctx->pbCertEncoded;
        cert.len = cert_ctx->cbCertEncoded;
        error = t->owner->certificate_check_cb((git_cert *) &cert, valid, t->connection_data.host, t->owner->cred_acquire_payload);