Kill ibuf_cat() since there is now ibuf_add_buf() in the official API.
authorclaudio <claudio@openbsd.org>
Tue, 18 Jul 2023 15:07:41 +0000 (15:07 +0000)
committerclaudio <claudio@openbsd.org>
Tue, 18 Jul 2023 15:07:41 +0000 (15:07 +0000)
OK tb@ tobhe@

sbin/iked/eap.c
sbin/iked/iked.h
sbin/iked/ikev2.c
sbin/iked/ikev2_msg.c
sbin/iked/imsg_util.c

index 06db86d..137398d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: eap.c,v 1.24 2023/05/23 13:57:14 claudio Exp $        */
+/*     $OpenBSD: eap.c,v 1.25 2023/07/18 15:07:41 claudio Exp $        */
 
 /*
  * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
@@ -112,7 +112,7 @@ eap_identity_request(struct iked *env, struct iked_sa *sa)
        if ((pld = ikev2_add_payload(e)) == NULL)
                goto done;
        firstpayload = IKEV2_PAYLOAD_IDr;
-       if (ibuf_cat(e, id->id_buf) != 0)
+       if (ibuf_add_buf(e, id->id_buf) != 0)
                goto done;
        len = ibuf_size(id->id_buf);
 
@@ -127,7 +127,7 @@ eap_identity_request(struct iked *env, struct iked_sa *sa)
                if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL)
                        goto done;
                cert->cert_type = certid->id_type;
-               if (ibuf_cat(e, certid->id_buf) != 0)
+               if (ibuf_add_buf(e, certid->id_buf) != 0)
                        goto done;
                len = ibuf_size(certid->id_buf) + sizeof(*cert);
 
@@ -142,7 +142,7 @@ eap_identity_request(struct iked *env, struct iked_sa *sa)
                        if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL)
                                goto done;
                        cert->cert_type = sa->sa_scert[i].id_type;
-                       if (ibuf_cat(e, sa->sa_scert[i].id_buf) != 0)
+                       if (ibuf_add_buf(e, sa->sa_scert[i].id_buf) != 0)
                                goto done;
                        len = ibuf_size(sa->sa_scert[i].id_buf) + sizeof(*cert);
                }
@@ -157,7 +157,7 @@ eap_identity_request(struct iked *env, struct iked_sa *sa)
        if ((auth = ibuf_reserve(e, sizeof(*auth))) == NULL)
                goto done;
        auth->auth_method = sa->sa_localauth.id_type;
-       if (ibuf_cat(e, sa->sa_localauth.id_buf) != 0)
+       if (ibuf_add_buf(e, sa->sa_localauth.id_buf) != 0)
                goto done;
        len = ibuf_size(sa->sa_localauth.id_buf) + sizeof(*auth);
 
index c08f35b..7b56e56 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: iked.h,v 1.221 2023/07/16 15:21:46 claudio Exp $      */
+/*     $OpenBSD: iked.h,v 1.222 2023/07/18 15:07:41 claudio Exp $      */
 
 /*
  * Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
@@ -1268,7 +1268,6 @@ struct ibuf *
         ibuf_new(const void *, size_t);
 struct ibuf *
         ibuf_static(void);
-int     ibuf_cat(struct ibuf *, struct ibuf *);
 size_t  ibuf_length(struct ibuf *);
 int     ibuf_setsize(struct ibuf *, size_t);
 struct ibuf *
index 349e16a..14e05a0 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ikev2.c,v 1.373 2023/07/16 15:21:46 claudio Exp $     */
+/*     $OpenBSD: ikev2.c,v 1.374 2023/07/18 15:07:41 claudio Exp $     */
 
 /*
  * Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
@@ -1609,7 +1609,7 @@ ikev2_init_ike_auth(struct iked *env, struct iked_sa *sa)
        if ((pld = ikev2_add_payload(e)) == NULL)
                goto done;
        firstpayload = IKEV2_PAYLOAD_IDi;
-       if (ibuf_cat(e, id->id_buf) != 0)
+       if (ibuf_add_buf(e, id->id_buf) != 0)
                goto done;
        len = ibuf_size(id->id_buf);
 
@@ -1623,7 +1623,7 @@ ikev2_init_ike_auth(struct iked *env, struct iked_sa *sa)
                        goto done;
                if ((pld = ikev2_add_payload(e)) == NULL)
                        goto done;
-               if (ibuf_cat(e, peerid.id_buf) != 0)
+               if (ibuf_add_buf(e, peerid.id_buf) != 0)
                        goto done;
                len = ibuf_size(peerid.id_buf);
        }
@@ -1639,7 +1639,7 @@ ikev2_init_ike_auth(struct iked *env, struct iked_sa *sa)
                if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL)
                        goto done;
                cert->cert_type = certid->id_type;
-               if (ibuf_cat(e, certid->id_buf) != 0)
+               if (ibuf_add_buf(e, certid->id_buf) != 0)
                        goto done;
                len = ibuf_size(certid->id_buf) + sizeof(*cert);
 
@@ -1654,7 +1654,7 @@ ikev2_init_ike_auth(struct iked *env, struct iked_sa *sa)
                        if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL)
                                goto done;
                        cert->cert_type = sa->sa_scert[i].id_type;
-                       if (ibuf_cat(e, sa->sa_scert[i].id_buf) != 0)
+                       if (ibuf_add_buf(e, sa->sa_scert[i].id_buf) != 0)
                                goto done;
                        len = ibuf_size(sa->sa_scert[i].id_buf) + sizeof(*cert);
                }
@@ -1679,7 +1679,7 @@ ikev2_init_ike_auth(struct iked *env, struct iked_sa *sa)
        if ((auth = ibuf_reserve(e, sizeof(*auth))) == NULL)
                goto done;
        auth->auth_method = sa->sa_localauth.id_type;
-       if (ibuf_cat(e, sa->sa_localauth.id_buf) != 0)
+       if (ibuf_add_buf(e, sa->sa_localauth.id_buf) != 0)
                goto done;
        len = ibuf_size(sa->sa_localauth.id_buf) + sizeof(*auth);
 
@@ -2212,7 +2212,7 @@ ikev2_add_vendor_id(struct ibuf *e, struct ikev2_payload **pld,
                        return (-1);
        if ((*pld = ikev2_add_payload(e)) == NULL)
                return (-1);
-       if (ibuf_cat(e, id) == -1)
+       if (ibuf_add_buf(e, id) == -1)
                return (-1);
 
        return (ibuf_length(id));
@@ -3908,7 +3908,7 @@ ikev2_resp_ike_auth(struct iked *env, struct iked_sa *sa)
                if ((pld = ikev2_add_payload(e)) == NULL)
                        goto done;
                firstpayload = IKEV2_PAYLOAD_IDr;
-               if (ibuf_cat(e, id->id_buf) != 0)
+               if (ibuf_add_buf(e, id->id_buf) != 0)
                        goto done;
                len = ibuf_size(id->id_buf);
 
@@ -3924,7 +3924,7 @@ ikev2_resp_ike_auth(struct iked *env, struct iked_sa *sa)
                        if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL)
                                goto done;
                        cert->cert_type = certid->id_type;
-                       if (ibuf_cat(e, certid->id_buf) != 0)
+                       if (ibuf_add_buf(e, certid->id_buf) != 0)
                                goto done;
                        len = ibuf_size(certid->id_buf) + sizeof(*cert);
 
@@ -3940,7 +3940,8 @@ ikev2_resp_ike_auth(struct iked *env, struct iked_sa *sa)
                                    sizeof(*cert))) == NULL)
                                        goto done;
                                cert->cert_type = sa->sa_scert[i].id_type;
-                               if (ibuf_cat(e, sa->sa_scert[i].id_buf) != 0)
+                               if (ibuf_add_buf(e, sa->sa_scert[i].id_buf) !=
+                                   0)
                                        goto done;
                                len = ibuf_size(sa->sa_scert[i].id_buf)
                                    + sizeof(*cert);
@@ -3958,7 +3959,7 @@ ikev2_resp_ike_auth(struct iked *env, struct iked_sa *sa)
        if ((auth = ibuf_reserve(e, sizeof(*auth))) == NULL)
                goto done;
        auth->auth_method = sa->sa_localauth.id_type;
-       if (ibuf_cat(e, sa->sa_localauth.id_buf) != 0)
+       if (ibuf_add_buf(e, sa->sa_localauth.id_buf) != 0)
                goto done;
        len = ibuf_size(sa->sa_localauth.id_buf) + sizeof(*auth);
 
@@ -4036,7 +4037,7 @@ ikev2_send_ike_e(struct iked *env, struct iked_sa *sa, struct ibuf *buf,
                goto done;
 
        if (buf) {
-               if (ibuf_cat(e, buf) != 0)
+               if (ibuf_add_buf(e, buf) != 0)
                        goto done;
 
                if (ikev2_next_payload(pld, ibuf_size(buf),
@@ -5320,7 +5321,7 @@ ikev2_send_informational(struct iked *env, struct iked_message *msg)
                        log_debug("%s: encryption failed", __func__);
                        goto done;
                }
-               if (ibuf_cat(buf, e) != 0)
+               if (ibuf_add_buf(buf, e) != 0)
                        goto done;
                if (ikev2_next_payload(pld, ibuf_size(e),
                    IKEV2_PAYLOAD_NOTIFY) == -1)
@@ -5351,7 +5352,7 @@ ikev2_send_informational(struct iked *env, struct iked_message *msg)
                    IKEV2_PAYLOAD_NOTIFY, IKEV2_EXCHANGE_INFORMATIONAL,
                    0)) == NULL)
                        goto done;
-               if (ibuf_cat(buf, e) != 0)
+               if (ibuf_add_buf(buf, e) != 0)
                        goto done;
                if (ikev2_set_header(hdr, ibuf_size(buf) - sizeof(*hdr)) == -1)
                        goto done;
@@ -6192,13 +6193,13 @@ ikev2_childsa_negotiate(struct iked *env, struct iked_sa *sa,
                            ibuf_length(kex->kex_dhpeer));
                        goto done;
                }
-               if (ibuf_cat(seed, dhsecret) != 0) {
+               if (ibuf_add_buf(seed, dhsecret) != 0) {
                        log_debug("%s: failed to set dh secret", __func__);
                        goto done;
                }
        }
-       if (ibuf_cat(seed, kex->kex_inonce) != 0 ||
-           ibuf_cat(seed, kex->kex_rnonce) != 0 ||
+       if (ibuf_add_buf(seed, kex->kex_inonce) != 0 ||
+           ibuf_add_buf(seed, kex->kex_rnonce) != 0 ||
            (keymat = ikev2_prfplus(sa->sa_prf,
            sa->sa_key_d, seed, ilen)) == NULL) {
                log_debug("%s: failed to get IKE SA key material", __func__);
index e694f8a..aa7e08d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ikev2_msg.c,v 1.96 2023/06/28 14:10:24 tobhe Exp $    */
+/*     $OpenBSD: ikev2_msg.c,v 1.97 2023/07/18 15:07:41 claudio Exp $  */
 
 /*
  * Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
@@ -300,7 +300,7 @@ ikev2_msg_send(struct iked *env, struct iked_message *msg)
                        log_debug("%s: failed to set NAT-T", __func__);
                        return (-1);
                }
-               if (ibuf_cat(new, buf) == -1) {
+               if (ibuf_add_buf(new, buf) == -1) {
                        ibuf_free(new);
                        log_debug("%s: failed to set NAT-T", __func__);
                        return (-1);
@@ -779,7 +779,7 @@ ikev2_msg_send_encrypt(struct iked *env, struct iked_sa *sa, struct ibuf **ep,
                log_debug("%s: encryption failed", __func__);
                goto done;
        }
-       if (ibuf_cat(buf, e) != 0)
+       if (ibuf_add_buf(buf, e) != 0)
                goto done;
 
        /* Add integrity checksum (HMAC) */
@@ -887,7 +887,7 @@ ikev2_send_encrypted_fragments(struct iked *env, struct iked_sa *sa,
                        log_debug("%s: encryption failed", __func__);
                        goto done;
                }
-               if (ibuf_cat(buf, e) != 0)
+               if (ibuf_add_buf(buf, e) != 0)
                        goto done;
 
                /* Add integrity checksum (HMAC) */
@@ -961,7 +961,7 @@ ikev2_msg_auth(struct iked *env, struct iked_sa *sa, int response)
 
        if ((authmsg = ibuf_dup(buf)) == NULL)
                return (NULL);
-       if (ibuf_cat(authmsg, nonce) != 0)
+       if (ibuf_add_buf(authmsg, nonce) != 0)
                goto fail;
 
        if ((hash_setkey(sa->sa_prf, ibuf_data(prfkey),
index 7c4a4d8..bf97af6 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: imsg_util.c,v 1.20 2023/07/16 15:21:46 claudio Exp $  */
+/*     $OpenBSD: imsg_util.c,v 1.21 2023/07/18 15:07:41 claudio Exp $  */
 
 /*
  * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
  * Extending the imsg buffer API for internal use
  */
 
-int
-ibuf_cat(struct ibuf *dst, struct ibuf *src)
-{
-       return (ibuf_add(dst, src->buf, ibuf_size(src)));
-}
-
 struct ibuf *
 ibuf_new(const void *data, size_t len)
 {