]> git.meshlink.io Git - meshlink/commitdiff
Fix signedness compiler warnings.
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 19 Mar 2006 13:06:21 +0000 (13:06 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 19 Mar 2006 13:06:21 +0000 (13:06 +0000)
src/meta.c
src/net.c
src/net_packet.c
src/net_setup.c
src/net_socket.c
src/protocol_auth.c
src/protocol_key.c
src/protocol_misc.c

index e376c33ba716ea9204e6d94bca36fd5b700a0c8b..77203f60c62f7209f7311ec30921b72aaec4265d 100644 (file)
@@ -60,8 +60,8 @@ bool send_meta(connection_t *c, const char *buffer, int length)
 
        /* Add our data to buffer */
        if(c->status.encryptout) {
-               result = EVP_EncryptUpdate(c->outctx, c->outbuf + c->outbufstart + c->outbuflen,
-                               &outlen, buffer, length);
+               result = EVP_EncryptUpdate(c->outctx, (unsigned char *)c->outbuf + c->outbufstart + c->outbuflen,
+                               &outlen, (unsigned char *)buffer, length);
                if(!result || outlen < length) {
                        logger(LOG_ERR, _("Error while encrypting metadata to %s (%s): %s"),
                                        c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
@@ -169,7 +169,7 @@ bool receive_meta(connection_t *c)
                /* Decrypt */
 
                if(c->status.decryptin && !decrypted) {
-                       result = EVP_DecryptUpdate(c->inctx, inbuf, &lenout, c->buffer + oldlen, lenin);
+                       result = EVP_DecryptUpdate(c->inctx, (unsigned char *)inbuf, &lenout, (unsigned char *)c->buffer + oldlen, lenin);
                        if(!result || lenout != lenin) {
                                logger(LOG_ERR, _("Error while decrypting metadata from %s (%s): %s"),
                                                c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
index a21850afd0c692038e244f8c37837325e6ee68a1..055d08b284648e37ae9ab94bb511800b75c5536b 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -288,7 +288,7 @@ static void check_network_activity(fd_set * readset, fd_set * writeset)
        connection_t *c;
        avl_node_t *node;
        int result, i;
-       int len = sizeof(result);
+       socklen_t len = sizeof(result);
        vpn_packet_t packet;
 
        cp();
@@ -411,9 +411,9 @@ int main_loop(void)
                        if(keyexpires < now) {
                                ifdebug(STATUS) logger(LOG_INFO, _("Regenerating symmetric key"));
 
-                               RAND_pseudo_bytes(myself->key, myself->keylength);
+                               RAND_pseudo_bytes((unsigned char *)myself->key, myself->keylength);
                                if(myself->cipher)
-                                       EVP_DecryptInit_ex(&packet_ctx, myself->cipher, NULL, myself->key, myself->key + myself->cipher->key_len);
+                                       EVP_DecryptInit_ex(&packet_ctx, myself->cipher, NULL, (unsigned char *)myself->key, (unsigned char *)myself->key + myself->cipher->key_len);
                                send_key_changed(broadcast, myself);
                                keyexpires = now + keylifetime;
                        }
index 06afc0b0c87a2ea79cf1ce2fd9e35aed8bc48cb3..d3e25c5e46ae8b7f452662743de688549caf9f35 100644 (file)
@@ -174,7 +174,7 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
        int nextpkt = 0;
        vpn_packet_t *outpkt = pkt[0];
        int outlen, outpad;
-       char hmac[EVP_MAX_MD_SIZE];
+       unsigned char hmac[EVP_MAX_MD_SIZE];
        int i;
 
        cp();
@@ -192,7 +192,7 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
        if(myself->digest && myself->maclength) {
                inpkt->len -= myself->maclength;
                HMAC(myself->digest, myself->key, myself->keylength,
-                        (char *) &inpkt->seqno, inpkt->len, hmac, NULL);
+                        (unsigned char *) &inpkt->seqno, inpkt->len, (unsigned char *)hmac, NULL);
 
                if(memcmp(hmac, (char *) &inpkt->seqno + inpkt->len, myself->maclength)) {
                        ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Got unauthenticated packet from %s (%s)"),
@@ -207,9 +207,9 @@ static void receive_udppacket(node_t *n, vpn_packet_t *inpkt)
                outpkt = pkt[nextpkt++];
 
                if(!EVP_DecryptInit_ex(&packet_ctx, NULL, NULL, NULL, NULL)
-                               || !EVP_DecryptUpdate(&packet_ctx, (char *) &outpkt->seqno, &outlen,
-                                       (char *) &inpkt->seqno, inpkt->len)
-                               || !EVP_DecryptFinal_ex(&packet_ctx, (char *) &outpkt->seqno + outlen, &outpad)) {
+                               || !EVP_DecryptUpdate(&packet_ctx, (unsigned char *) &outpkt->seqno, &outlen,
+                                       (unsigned char *) &inpkt->seqno, inpkt->len)
+                               || !EVP_DecryptFinal_ex(&packet_ctx, (unsigned char *) &outpkt->seqno + outlen, &outpad)) {
                        ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Error decrypting packet from %s (%s): %s"),
                                                n->name, n->hostname, ERR_error_string(ERR_get_error(), NULL));
                        return;
@@ -352,9 +352,9 @@ static void send_udppacket(node_t *n, vpn_packet_t *inpkt)
                outpkt = pkt[nextpkt++];
 
                if(!EVP_EncryptInit_ex(&n->packet_ctx, NULL, NULL, NULL, NULL)
-                               || !EVP_EncryptUpdate(&n->packet_ctx, (char *) &outpkt->seqno, &outlen,
-                                       (char *) &inpkt->seqno, inpkt->len)
-                               || !EVP_EncryptFinal_ex(&n->packet_ctx, (char *) &outpkt->seqno + outlen, &outpad)) {
+                               || !EVP_EncryptUpdate(&n->packet_ctx, (unsigned char *) &outpkt->seqno, &outlen,
+                                       (unsigned char *) &inpkt->seqno, inpkt->len)
+                               || !EVP_EncryptFinal_ex(&n->packet_ctx, (unsigned char *) &outpkt->seqno + outlen, &outpad)) {
                        ifdebug(TRAFFIC) logger(LOG_ERR, _("Error while encrypting packet to %s (%s): %s"),
                                                n->name, n->hostname, ERR_error_string(ERR_get_error(), NULL));
                        goto end;
@@ -367,8 +367,8 @@ static void send_udppacket(node_t *n, vpn_packet_t *inpkt)
        /* Add the message authentication code */
 
        if(n->digest && n->maclength) {
-               HMAC(n->digest, n->key, n->keylength, (char *) &inpkt->seqno,
-                        inpkt->len, (char *) &inpkt->seqno + inpkt->len, &outlen);
+               HMAC(n->digest, n->key, n->keylength, (unsigned char *) &inpkt->seqno,
+                        inpkt->len, (unsigned char *) &inpkt->seqno + inpkt->len, NULL);
                inpkt->len += n->maclength;
        }
 
index e0f156969486351f762f627acf8353762afee8b8..e447a1f99090633a03e6b09002d58555595a62ee 100644 (file)
@@ -368,7 +368,7 @@ bool setup_myself(void)
        myself->connection->outcipher = EVP_bf_ofb();
 
        myself->key = xmalloc(myself->keylength);
-       RAND_pseudo_bytes(myself->key, myself->keylength);
+       RAND_pseudo_bytes((unsigned char *)myself->key, myself->keylength);
 
        if(!get_config_int(lookup_config(config_tree, "KeyExpire"), &keylifetime))
                keylifetime = 3600;
@@ -377,7 +377,7 @@ bool setup_myself(void)
        
        if(myself->cipher) {
                EVP_CIPHER_CTX_init(&packet_ctx);
-               if(!EVP_DecryptInit_ex(&packet_ctx, myself->cipher, NULL, myself->key, myself->key + myself->cipher->key_len)) {
+               if(!EVP_DecryptInit_ex(&packet_ctx, myself->cipher, NULL, (unsigned char *)myself->key, (unsigned char *)myself->key + myself->cipher->key_len)) {
                        logger(LOG_ERR, _("Error during initialisation of cipher for %s (%s): %s"),
                                        myself->name, myself->hostname, ERR_error_string(ERR_get_error(), NULL));
                        return false;
index fb776f89fc649edd94bd73dceecdbd64b34152b5..fcd5fecb3ee2e8b39ecfaa4f5159e5965adc0ca8 100644 (file)
@@ -391,7 +391,8 @@ bool handle_new_meta_connection(int sock)
        int option;
        connection_t *c;
        sockaddr_t sa;
-       int fd, len = sizeof(sa);
+       int fd;
+       socklen_t len = sizeof(sa);
 
        cp();
 
index c44c6d01ce998cee3a0fc4fe5213d34c492641f8..4c885623f34b755eecbc173418af4258cf24714e 100644 (file)
@@ -138,7 +138,7 @@ bool send_metakey(connection_t *c)
        cp();
        /* Copy random data to the buffer */
 
-       RAND_pseudo_bytes(c->outkey, len);
+       RAND_pseudo_bytes((unsigned char *)c->outkey, len);
 
        /* The message we send must be smaller than the modulus of the RSA key.
           By definition, for a key of k bits, the following formula holds:
@@ -166,7 +166,7 @@ bool send_metakey(connection_t *c)
           with a length equal to that of the modulus of the RSA key.
         */
 
-       if(RSA_public_encrypt(len, c->outkey, buffer, c->rsa_key, RSA_NO_PADDING) != len) {
+       if(RSA_public_encrypt(len, (unsigned char *)c->outkey, (unsigned char *)buffer, c->rsa_key, RSA_NO_PADDING) != len) {
                logger(LOG_ERR, _("Error during encryption of meta key for %s (%s)"),
                           c->name, c->hostname);
                return false;
@@ -188,8 +188,8 @@ bool send_metakey(connection_t *c)
 
        if(c->outcipher) {
                if(!EVP_EncryptInit(c->outctx, c->outcipher,
-                                       c->outkey + len - c->outcipher->key_len,
-                                       c->outkey + len - c->outcipher->key_len -
+                                       (unsigned char *)c->outkey + len - c->outcipher->key_len,
+                                       (unsigned char *)c->outkey + len - c->outcipher->key_len -
                                        c->outcipher->iv_len)) {
                        logger(LOG_ERR, _("Error during initialisation of cipher for %s (%s): %s"),
                                        c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
@@ -239,7 +239,7 @@ bool metakey_h(connection_t *c)
 
        /* Decrypt the meta key */
 
-       if(RSA_private_decrypt(len, buffer, c->inkey, myself->connection->rsa_key, RSA_NO_PADDING) != len) {    /* See challenge() */
+       if(RSA_private_decrypt(len, (unsigned char *)buffer, (unsigned char *)c->inkey, myself->connection->rsa_key, RSA_NO_PADDING) != len) {  /* See challenge() */
                logger(LOG_ERR, _("Error during encryption of meta key for %s (%s)"),
                           c->name, c->hostname);
                return false;
@@ -264,8 +264,8 @@ bool metakey_h(connection_t *c)
                }
 
                if(!EVP_DecryptInit(c->inctx, c->incipher,
-                                       c->inkey + len - c->incipher->key_len,
-                                       c->inkey + len - c->incipher->key_len -
+                                       (unsigned char *)c->inkey + len - c->incipher->key_len,
+                                       (unsigned char *)c->inkey + len - c->incipher->key_len -
                                        c->incipher->iv_len)) {
                        logger(LOG_ERR, _("Error during initialisation of cipher from %s (%s): %s"),
                                        c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
@@ -322,7 +322,7 @@ bool send_challenge(connection_t *c)
 
        /* Copy random data to the buffer */
 
-       RAND_pseudo_bytes(c->hischallenge, len);
+       RAND_pseudo_bytes((unsigned char *)c->hischallenge, len);
 
        /* Convert to hex */
 
@@ -384,7 +384,7 @@ bool send_chal_reply(connection_t *c)
 
        if(!EVP_DigestInit(&ctx, c->indigest)
                        || !EVP_DigestUpdate(&ctx, c->mychallenge, RSA_size(myself->connection->rsa_key))
-                       || !EVP_DigestFinal(&ctx, hash, NULL)) {
+                       || !EVP_DigestFinal(&ctx, (unsigned char *)hash, NULL)) {
                logger(LOG_ERR, _("Error during calculation of response for %s (%s): %s"),
                        c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
                return false;
@@ -430,7 +430,7 @@ bool chal_reply_h(connection_t *c)
 
        if(!EVP_DigestInit(&ctx, c->outdigest)
                        || !EVP_DigestUpdate(&ctx, c->hischallenge, RSA_size(c->rsa_key))
-                       || !EVP_DigestFinal(&ctx, myhash, NULL)) {
+                       || !EVP_DigestFinal(&ctx, (unsigned char *)myhash, NULL)) {
                logger(LOG_ERR, _("Error during calculation of response from %s (%s): %s"),
                        c->name, c->hostname, ERR_error_string(ERR_get_error(), NULL));
                return false;
index e393dd64a945216ce28a36b2dbe88661e9678e18..591bb66026d024b8a3e7b017496286563cca116e 100644 (file)
@@ -262,7 +262,7 @@ bool ans_key_h(connection_t *c)
        from->compression = compression;
 
        if(from->cipher)
-               if(!EVP_EncryptInit_ex(&from->packet_ctx, from->cipher, NULL, from->key, from->key + from->cipher->key_len)) {
+               if(!EVP_EncryptInit_ex(&from->packet_ctx, from->cipher, NULL, (unsigned char *)from->key, (unsigned char *)from->key + from->cipher->key_len)) {
                        logger(LOG_ERR, _("Error during initialisation of key from %s (%s): %s"),
                                        from->name, from->hostname, ERR_error_string(ERR_get_error(), NULL));
                        return false;
index b2f6ddc5f3f0e3b8e4ea3cd41d09ec54b1f10ec8..0b893a677a653403aa59dd22aa5535ddfd62c0ed 100644 (file)
@@ -163,7 +163,7 @@ bool send_tcppacket(connection_t *c, vpn_packet_t *packet)
        if(!send_request(c, "%d %hd", PACKET, packet->len))
                return false;
 
-       return send_meta(c, packet->data, packet->len);
+       return send_meta(c, (char *)packet->data, packet->len);
 }
 
 bool tcppacket_h(connection_t *c)