On Tue, May 23, 2023 at 03:20:27PM +0200, Claudio Jeker wrote: > Another mechanical diff. Replace ibuf_advance() with ibuf_reserve(). > > Again ibuf_advance() just calls ibuf_reserve().
ok too > -- > :wq Claudio > > Index: eap.c > =================================================================== > RCS file: /cvs/src/sbin/iked/eap.c,v > retrieving revision 1.23 > diff -u -p -r1.23 eap.c > --- eap.c 23 May 2023 13:12:19 -0000 1.23 > +++ eap.c 23 May 2023 13:16:04 -0000 > @@ -51,7 +51,7 @@ eap_add_id_request(struct ibuf *e) > { > struct eap_message *eap; > > - if ((eap = ibuf_advance(e, sizeof(*eap))) == NULL) > + if ((eap = ibuf_reserve(e, sizeof(*eap))) == NULL) > return (-1); > eap->eap_code = EAP_CODE_REQUEST; > eap->eap_id = 0; > @@ -124,7 +124,7 @@ eap_identity_request(struct iked *env, s > /* CERT payload */ > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((cert = ibuf_advance(e, sizeof(*cert))) == NULL) > + if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL) > goto done; > cert->cert_type = certid->id_type; > if (ibuf_cat(e, certid->id_buf) != 0) > @@ -139,7 +139,7 @@ eap_identity_request(struct iked *env, s > goto done; > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((cert = ibuf_advance(e, sizeof(*cert))) == NULL) > + 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) > @@ -154,7 +154,7 @@ eap_identity_request(struct iked *env, s > /* AUTH payload */ > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((auth = ibuf_advance(e, sizeof(*auth))) == NULL) > + 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) > @@ -193,7 +193,7 @@ eap_challenge_request(struct iked *env, > if ((e = ibuf_static()) == NULL) > return (-1); > > - if ((eap = ibuf_advance(e, sizeof(*eap))) == NULL) > + if ((eap = ibuf_reserve(e, sizeof(*eap))) == NULL) > goto done; > eap->eap_code = EAP_CODE_REQUEST; > eap->eap_id = eap_id + 1; > @@ -205,7 +205,7 @@ eap_challenge_request(struct iked *env, > eap->eap_length = htobe16(sizeof(*eap) + > sizeof(*ms) + strlen(name)); > > - if ((ms = ibuf_advance(e, sizeof(*ms))) == NULL) > + if ((ms = ibuf_reserve(e, sizeof(*ms))) == NULL) > return (-1); > ms->msc_opcode = EAP_MSOPCODE_CHALLENGE; > ms->msc_id = eap->eap_id; > @@ -244,7 +244,7 @@ eap_message_send(struct iked *env, struc > if ((e = ibuf_static()) == NULL) > return (-1); > > - if ((resp = ibuf_advance(e, sizeof(*resp))) == NULL) > + if ((resp = ibuf_reserve(e, sizeof(*resp))) == NULL) > goto done; > resp->eap_code = eap_code; > resp->eap_id = eap_id; > @@ -278,7 +278,7 @@ eap_mschap_challenge(struct iked *env, s > > msg = " M=Welcome"; > > - if ((resp = ibuf_advance(eapmsg, sizeof(*resp))) == NULL) > + if ((resp = ibuf_reserve(eapmsg, sizeof(*resp))) == NULL) > goto done; > resp->eap_code = EAP_CODE_REQUEST; > resp->eap_id = eap_id + 1; > @@ -286,7 +286,7 @@ eap_mschap_challenge(struct iked *env, s > success_size + strlen(msg)); > resp->eap_type = EAP_TYPE_MSCHAP_V2; > > - if ((mss = ibuf_advance(eapmsg, sizeof(*mss))) == NULL) > + if ((mss = ibuf_reserve(eapmsg, sizeof(*mss))) == NULL) > goto done; > mss->mss_opcode = EAP_MSOPCODE_SUCCESS; > mss->mss_id = msr_id; > @@ -314,13 +314,13 @@ eap_mschap_success(struct iked *env, str > > if ((eapmsg = ibuf_static()) == NULL) > return (-1); > - if ((resp = ibuf_advance(eapmsg, sizeof(*resp))) == NULL) > + if ((resp = ibuf_reserve(eapmsg, sizeof(*resp))) == NULL) > goto done; > resp->eap_code = EAP_CODE_RESPONSE; > resp->eap_id = eap_id; > resp->eap_length = htobe16(sizeof(*resp) + sizeof(*ms)); > resp->eap_type = EAP_TYPE_MSCHAP_V2; > - if ((ms = ibuf_advance(eapmsg, sizeof(*ms))) == NULL) > + if ((ms = ibuf_reserve(eapmsg, sizeof(*ms))) == NULL) > goto done; > ms->ms_opcode = EAP_MSOPCODE_SUCCESS; > > Index: iked.h > =================================================================== > RCS file: /cvs/src/sbin/iked/iked.h,v > retrieving revision 1.212 > diff -u -p -r1.212 iked.h > --- iked.h 23 May 2023 13:12:19 -0000 1.212 > +++ iked.h 23 May 2023 13:16:05 -0000 > @@ -1280,7 +1280,6 @@ struct ibuf * > struct ibuf * > ibuf_random(size_t); > int ibuf_prepend(struct ibuf *, void *, size_t); > -void *ibuf_advance(struct ibuf *, size_t); > int ibuf_strcat(struct ibuf **, const char *); > int ibuf_strlen(struct ibuf *); > > Index: ikev2.c > =================================================================== > RCS file: /cvs/src/sbin/iked/ikev2.c,v > retrieving revision 1.366 > diff -u -p -r1.366 ikev2.c > --- ikev2.c 23 May 2023 13:12:19 -0000 1.366 > +++ ikev2.c 23 May 2023 13:16:08 -0000 > @@ -1414,7 +1414,7 @@ ikev2_init_ike_sa_peer(struct iked *env, > if (cookie) { > if ((pld = ikev2_add_payload(buf)) == NULL) > goto done; > - if ((n = ibuf_advance(buf, sizeof(*n))) == NULL) > + if ((n = ibuf_reserve(buf, sizeof(*n))) == NULL) > goto done; > n->n_protoid = IKEV2_SAPROTO_NONE; > n->n_spisize = 0; > @@ -1444,7 +1444,7 @@ ikev2_init_ike_sa_peer(struct iked *env, > /* KE payload */ > if ((pld = ikev2_add_payload(buf)) == NULL) > goto done; > - if ((ke = ibuf_advance(buf, sizeof(*ke))) == NULL) > + if ((ke = ibuf_reserve(buf, sizeof(*ke))) == NULL) > goto done; > if ((group = sa->sa_dhgroup) == NULL) { > log_debug("%s: invalid dh", __func__); > @@ -1618,7 +1618,7 @@ ikev2_init_ike_auth(struct iked *env, st > goto done; > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((cert = ibuf_advance(e, sizeof(*cert))) == NULL) > + if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL) > goto done; > cert->cert_type = certid->id_type; > if (ibuf_cat(e, certid->id_buf) != 0) > @@ -1633,7 +1633,7 @@ ikev2_init_ike_auth(struct iked *env, st > goto done; > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((cert = ibuf_advance(e, sizeof(*cert))) == NULL) > + 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) > @@ -1658,7 +1658,7 @@ ikev2_init_ike_auth(struct iked *env, st > /* AUTH payload */ > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((auth = ibuf_advance(e, sizeof(*auth))) == NULL) > + 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) > @@ -1869,7 +1869,7 @@ ikev2_add_header(struct ibuf *buf, struc > { > struct ike_header *hdr; > > - if ((hdr = ibuf_advance(buf, sizeof(*hdr))) == NULL) { > + if ((hdr = ibuf_reserve(buf, sizeof(*hdr))) == NULL) { > log_debug("%s: failed to add header", __func__); > return (NULL); > } > @@ -1909,7 +1909,7 @@ ikev2_add_payload(struct ibuf *buf) > { > struct ikev2_payload *pld; > > - if ((pld = ibuf_advance(buf, sizeof(*pld))) == NULL) { > + if ((pld = ibuf_reserve(buf, sizeof(*pld))) == NULL) { > log_debug("%s: failed to add payload", __func__); > return (NULL); > } > @@ -1938,7 +1938,7 @@ ikev2_add_ts_payload(struct ibuf *buf, u > > bzero(&pooladdr, sizeof(pooladdr)); > > - if ((tsp = ibuf_advance(buf, sizeof(*tsp))) == NULL) > + if ((tsp = ibuf_reserve(buf, sizeof(*tsp))) == NULL) > return (-1); > len = sizeof(*tsp); > > @@ -1962,7 +1962,7 @@ ikev2_add_ts_payload(struct ibuf *buf, u > return (-1); > > TAILQ_FOREACH(tsi, tss, ts_entry) { > - if ((ts = ibuf_advance(buf, sizeof(*ts))) == NULL) > + if ((ts = ibuf_reserve(buf, sizeof(*ts))) == NULL) > return (-1); > > addr = &tsi->ts_addr; > @@ -1989,7 +1989,7 @@ ikev2_add_ts_payload(struct ibuf *buf, u > ts->ts_type = IKEV2_TS_IPV4_ADDR_RANGE; > ts->ts_length = htobe16(sizeof(*ts) + 8); > > - if ((ptr = ibuf_advance(buf, 8)) == NULL) > + if ((ptr = ibuf_reserve(buf, 8)) == NULL) > return (-1); > > in4 = (struct sockaddr_in *)&addr->addr; > @@ -2008,7 +2008,7 @@ ikev2_add_ts_payload(struct ibuf *buf, u > ts->ts_type = IKEV2_TS_IPV6_ADDR_RANGE; > ts->ts_length = htobe16(sizeof(*ts) + 32); > > - if ((ptr = ibuf_advance(buf, 32)) == NULL) > + if ((ptr = ibuf_reserve(buf, 32)) == NULL) > return (-1); > > in6 = (struct sockaddr_in6 *)&addr->addr; > @@ -2083,7 +2083,7 @@ ikev2_add_certreq(struct ibuf *e, struct > if ((*pld = ikev2_add_payload(e)) == NULL) > return (-1); > > - if ((cert = ibuf_advance(e, sizeof(*cert))) == NULL) > + if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL) > return (-1); > > cert->cert_type = type; > @@ -2149,7 +2149,7 @@ ikev2_add_ipcompnotify(struct iked *env, > if ((*pld = ikev2_add_payload(e)) == NULL) > return (-1); > len = sizeof(*n) + sizeof(cpi) + sizeof(transform); > - if ((ptr = ibuf_advance(e, len)) == NULL) > + if ((ptr = ibuf_reserve(e, len)) == NULL) > return (-1); > n = (struct ikev2_notify *)ptr; > n->n_protoid = 0; > @@ -2175,7 +2175,7 @@ ikev2_add_notify(struct ibuf *e, struct > if ((*pld = ikev2_add_payload(e)) == NULL) > return (-1); > len = sizeof(*n); > - if ((n = ibuf_advance(e, len)) == NULL) > + if ((n = ibuf_reserve(e, len)) == NULL) > return (-1); > n->n_protoid = 0; > n->n_spisize = 0; > @@ -2235,7 +2235,7 @@ ikev2_add_sighashnotify(struct ibuf *e, > /* NOTIFY payload */ > if ((*pld = ikev2_add_payload(e)) == NULL) > return (-1); > - if ((ptr = ibuf_advance(e, len)) == NULL) > + if ((ptr = ibuf_reserve(e, len)) == NULL) > return (-1); > > n = (struct ikev2_notify *)ptr; > @@ -2397,11 +2397,11 @@ ikev2_add_nat_detection(struct iked *env > /* NAT-T notify payloads */ > if ((*pld = ikev2_add_payload(buf)) == NULL) > return (-1); > - if ((n = ibuf_advance(buf, sizeof(*n))) == NULL) > + if ((n = ibuf_reserve(buf, sizeof(*n))) == NULL) > return (-1); > n->n_type = htobe16(IKEV2_N_NAT_DETECTION_SOURCE_IP); > len = ikev2_nat_detection(env, msg, NULL, 0, 0, 0); > - if ((ptr = ibuf_advance(buf, len)) == NULL) > + if ((ptr = ibuf_reserve(buf, len)) == NULL) > return (-1); > if ((len = ikev2_nat_detection(env, msg, ptr, len, > betoh16(n->n_type), 0)) == -1) > @@ -2413,11 +2413,11 @@ ikev2_add_nat_detection(struct iked *env > > if ((*pld = ikev2_add_payload(buf)) == NULL) > return (-1); > - if ((n = ibuf_advance(buf, sizeof(*n))) == NULL) > + if ((n = ibuf_reserve(buf, sizeof(*n))) == NULL) > return (-1); > n->n_type = htobe16(IKEV2_N_NAT_DETECTION_DESTINATION_IP); > len = ikev2_nat_detection(env, msg, NULL, 0, 0, 0); > - if ((ptr = ibuf_advance(buf, len)) == NULL) > + if ((ptr = ibuf_reserve(buf, len)) == NULL) > return (-1); > if ((len = ikev2_nat_detection(env, msg, ptr, len, > betoh16(n->n_type), 0)) == -1) > @@ -2442,7 +2442,7 @@ ikev2_add_cp(struct iked *env, struct ik > int sent_addr4 = 0, sent_addr6 = 0; > int have_mask4 = 0, sent_mask4 = 0; > > - if ((cp = ibuf_advance(buf, sizeof(*cp))) == NULL) > + if ((cp = ibuf_reserve(buf, sizeof(*cp))) == NULL) > return (-1); > len = sizeof(*cp); > > @@ -2474,7 +2474,7 @@ ikev2_add_cp(struct iked *env, struct ik > } > } > > - if ((cfg = ibuf_advance(buf, sizeof(*cfg))) == NULL) > + if ((cfg = ibuf_reserve(buf, sizeof(*cfg))) == NULL) > return (-1); > > cfg->cfg_type = htobe16(ikecfg->cfg_type); > @@ -2569,7 +2569,7 @@ ikev2_add_cp(struct iked *env, struct ik > > /* derive netmask from pool */ > if (type == IKEV2_CP_REPLY && have_mask4 && !sent_mask4) { > - if ((cfg = ibuf_advance(buf, sizeof(*cfg))) == NULL) > + if ((cfg = ibuf_reserve(buf, sizeof(*cfg))) == NULL) > return (-1); > cfg->cfg_type = htobe16(IKEV2_CFG_INTERNAL_IP4_NETMASK); > len += sizeof(*cfg); > @@ -2647,7 +2647,7 @@ ikev2_add_proposals(struct iked *env, st > prop->prop_localspi.spi_protoid = prop->prop_protoid; > } > > - if ((sap = ibuf_advance(buf, sizeof(*sap))) == NULL) { > + if ((sap = ibuf_reserve(buf, sizeof(*sap))) == NULL) { > log_debug("%s: failed to add proposal", __func__); > return (-1); > } > @@ -2751,7 +2751,7 @@ ikev2_add_transform(struct ibuf *buf, > struct ikev2_transform *xfrm; > struct ikev2_attribute *attr; > > - if ((xfrm = ibuf_advance(buf, sizeof(*xfrm))) == NULL) { > + if ((xfrm = ibuf_reserve(buf, sizeof(*xfrm))) == NULL) { > log_debug("%s: failed to add transform", __func__); > return (-1); > } > @@ -2762,7 +2762,7 @@ ikev2_add_transform(struct ibuf *buf, > if (length) { > xfrm->xfrm_length = htobe16(sizeof(*xfrm) + sizeof(*attr)); > > - if ((attr = ibuf_advance(buf, sizeof(*attr))) == NULL) { > + if ((attr = ibuf_reserve(buf, sizeof(*attr))) == NULL) { > log_debug("%s: failed to add attribute", __func__); > return (-1); > } > @@ -2780,7 +2780,7 @@ ikev2_add_data(struct ibuf *buf, void *d > { > void *msgbuf; > > - if ((msgbuf = ibuf_advance(buf, length)) == NULL) { > + if ((msgbuf = ibuf_reserve(buf, length)) == NULL) { > log_debug("%s: failed", __func__); > return (-1); > } > @@ -2794,7 +2794,7 @@ ikev2_add_buf(struct ibuf *buf, struct i > { > void *msgbuf; > > - if ((msgbuf = ibuf_advance(buf, ibuf_size(data))) == NULL) { > + if ((msgbuf = ibuf_reserve(buf, ibuf_size(data))) == NULL) { > log_debug("%s: failed", __func__); > return (-1); > } > @@ -2846,7 +2846,7 @@ ikev2_resp_informational(struct iked *en > } > if ((pld = ikev2_add_payload(buf)) == NULL) > goto done; > - if ((n = ibuf_advance(buf, sizeof(*n))) == NULL) > + if ((n = ibuf_reserve(buf, sizeof(*n))) == NULL) > goto done; > n->n_protoid = IKEV2_SAPROTO_IKE; > n->n_spisize = 0; > @@ -3117,7 +3117,7 @@ ikev2_handle_delete(struct iked *env, st > goto done; > *firstpayload = IKEV2_PAYLOAD_DELETE; > > - if ((localdel = ibuf_advance(resp, sizeof(*localdel))) == NULL) > + if ((localdel = ibuf_reserve(resp, sizeof(*localdel))) == NULL) > goto done; > > localdel->del_protoid = msg->msg_del_protoid; > @@ -3363,7 +3363,7 @@ ikev2_resp_ike_sa_init(struct iked *env, > /* KE payload */ > if ((pld = ikev2_add_payload(buf)) == NULL) > goto done; > - if ((ke = ibuf_advance(buf, sizeof(*ke))) == NULL) > + if ((ke = ibuf_reserve(buf, sizeof(*ke))) == NULL) > goto done; > if ((group = sa->sa_dhgroup) == NULL) { > log_debug("%s: invalid dh", __func__); > @@ -3464,7 +3464,7 @@ ikev2_send_auth_failed(struct iked *env, > /* Notify payload */ > if ((buf = ibuf_static()) == NULL) > goto done; > - if ((n = ibuf_advance(buf, sizeof(*n))) == NULL) > + if ((n = ibuf_reserve(buf, sizeof(*n))) == NULL) > goto done; > n->n_protoid = IKEV2_SAPROTO_IKE; > n->n_spisize = 0; > @@ -3519,7 +3519,7 @@ ikev2_add_error(struct iked *env, struct > log_info("%s: %s", SPI_SA(msg->msg_sa, __func__), > print_map(msg->msg_error, ikev2_n_map)); > len = sizeof(*n); > - if ((ptr = ibuf_advance(buf, len)) == NULL) > + if ((ptr = ibuf_reserve(buf, len)) == NULL) > return (-1); > n = (struct ikev2_notify *)ptr; > n->n_type = htobe16(msg->msg_error); > @@ -3896,7 +3896,7 @@ ikev2_resp_ike_auth(struct iked *env, st > > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((cert = ibuf_advance(e, sizeof(*cert))) == NULL) > + if ((cert = ibuf_reserve(e, sizeof(*cert))) == NULL) > goto done; > cert->cert_type = certid->id_type; > if (ibuf_cat(e, certid->id_buf) != 0) > @@ -3911,7 +3911,7 @@ ikev2_resp_ike_auth(struct iked *env, st > goto done; > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((cert = ibuf_advance(e, > + if ((cert = ibuf_reserve(e, > sizeof(*cert))) == NULL) > goto done; > cert->cert_type = sa->sa_scert[i].id_type; > @@ -3930,7 +3930,7 @@ ikev2_resp_ike_auth(struct iked *env, st > /* AUTH payload */ > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((auth = ibuf_advance(e, sizeof(*auth))) == NULL) > + 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) > @@ -4175,7 +4175,7 @@ ikev2_send_create_child_sa(struct iked * > /* KE payload */ > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((ke = ibuf_advance(e, sizeof(*ke))) == NULL) > + if ((ke = ibuf_reserve(e, sizeof(*ke))) == NULL) > goto done; > if ((group = sa->sa_dhgroup) == NULL) { > log_debug("%s: invalid dh", __func__); > @@ -4197,12 +4197,12 @@ ikev2_send_create_child_sa(struct iked * > /* REKEY_SA notification */ > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((n = ibuf_advance(e, sizeof(*n))) == NULL) > + if ((n = ibuf_reserve(e, sizeof(*n))) == NULL) > goto done; > n->n_type = htobe16(IKEV2_N_REKEY_SA); > n->n_protoid = rekey->spi_protoid; > n->n_spisize = rekey->spi_size; > - if ((ptr = ibuf_advance(e, rekey->spi_size)) == NULL) > + if ((ptr = ibuf_reserve(e, rekey->spi_size)) == NULL) > goto done; > len = rekey->spi_size; > spi = htobe32((uint32_t)csa->csa_peerspi); > @@ -4308,7 +4308,7 @@ ikev2_ike_sa_rekey(struct iked *env, voi > /* KE payload */ > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((ke = ibuf_advance(e, sizeof(*ke))) == NULL) > + if ((ke = ibuf_reserve(e, sizeof(*ke))) == NULL) > goto done; > if ((group = nsa->sa_dhgroup) == NULL) { > log_debug("%s: invalid dh", __func__); > @@ -4558,7 +4558,7 @@ ikev2_init_create_child_sa(struct iked * > if ((buf = ibuf_static()) == NULL) > goto done; > > - if ((del = ibuf_advance(buf, sizeof(*del))) == NULL) > + if ((del = ibuf_reserve(buf, sizeof(*del))) == NULL) > goto done; > > del->del_protoid = prop->prop_protoid; > @@ -4757,7 +4757,7 @@ ikev2_ikesa_delete(struct iked *env, str > /* Send PAYLOAD_DELETE */ > if ((buf = ibuf_static()) == NULL) > goto done; > - if ((del = ibuf_advance(buf, sizeof(*del))) == NULL) > + if ((del = ibuf_reserve(buf, sizeof(*del))) == NULL) > goto done; > del->del_protoid = IKEV2_SAPROTO_IKE; > del->del_spisize = 0; > @@ -5043,7 +5043,7 @@ ikev2_resp_create_child_sa(struct iked * > /* KE payload */ > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > - if ((ke = ibuf_advance(e, sizeof(*ke))) == NULL) > + if ((ke = ibuf_reserve(e, sizeof(*ke))) == NULL) > goto done; > if (kex->kex_dhgroup == NULL) { > log_debug("%s: invalid dh", __func__); > @@ -5255,7 +5255,7 @@ ikev2_send_informational(struct iked *en > if ((pld = ikev2_add_payload(e)) == NULL) > goto done; > > - if ((n = ibuf_advance(e, sizeof(*n))) == NULL) > + if ((n = ibuf_reserve(e, sizeof(*n))) == NULL) > goto done; > n->n_protoid = IKEV2_SAPROTO_IKE; /* XXX ESP etc. */ > n->n_spisize = 0; > @@ -6055,7 +6055,7 @@ ikev2_childsa_delete_proposed(struct ike > return (0); > if ((buf = ibuf_static()) == NULL) > return (-1); > - if ((del = ibuf_advance(buf, sizeof(*del))) == NULL) > + if ((del = ibuf_reserve(buf, sizeof(*del))) == NULL) > goto done; > /* XXX we assume all have the same protoid */ > del->del_protoid = protoid; > @@ -6850,7 +6850,7 @@ ikev2_child_sa_drop(struct iked *env, st > > if ((buf = ibuf_static()) == NULL) > return (0); > - if ((del = ibuf_advance(buf, sizeof(*del))) == NULL) > + if ((del = ibuf_reserve(buf, sizeof(*del))) == NULL) > goto done; > del->del_protoid = drop->spi_protoid; > del->del_spisize = 4; > Index: ikev2_msg.c > =================================================================== > RCS file: /cvs/src/sbin/iked/ikev2_msg.c,v > retrieving revision 1.91 > diff -u -p -r1.91 ikev2_msg.c > --- ikev2_msg.c 23 May 2023 13:12:19 -0000 1.91 > +++ ikev2_msg.c 23 May 2023 13:16:08 -0000 > @@ -425,7 +425,7 @@ ikev2_msg_encrypt(struct iked *env, stru > * Pad the payload and encrypt it > */ > if (pad) { > - if ((ptr = ibuf_advance(src, pad)) == NULL) > + if ((ptr = ibuf_reserve(src, pad)) == NULL) > goto done; > arc4random_buf(ptr, pad); > } > @@ -470,7 +470,7 @@ ikev2_msg_encrypt(struct iked *env, stru > if (outlen && ibuf_add(dst, ibuf_data(out), outlen) != 0) > goto done; > > - if ((ptr = ibuf_advance(dst, integrlen)) == NULL) > + if ((ptr = ibuf_reserve(dst, integrlen)) == NULL) > goto done; > explicit_bzero(ptr, integrlen); > > @@ -852,7 +852,7 @@ ikev2_send_encrypted_fragments(struct ik > goto done; > > /* Fragment header */ > - if ((frag = ibuf_advance(buf, sizeof(*frag))) == NULL) { > + if ((frag = ibuf_reserve(buf, sizeof(*frag))) == NULL) { > log_debug("%s: failed to add SKF fragment header", > __func__); > goto done; > @@ -959,7 +959,7 @@ ikev2_msg_auth(struct iked *env, struct > if (hash_keylength(sa->sa_prf) != hash_length(sa->sa_prf)) > goto fail; > > - if ((ptr = ibuf_advance(authmsg, hash_keylength(sa->sa_prf))) == NULL) > + if ((ptr = ibuf_reserve(authmsg, hash_keylength(sa->sa_prf))) == NULL) > goto fail; > > hash_init(sa->sa_prf); > Index: imsg_util.c > =================================================================== > RCS file: /cvs/src/sbin/iked/imsg_util.c,v > retrieving revision 1.15 > diff -u -p -r1.15 imsg_util.c > --- imsg_util.c 23 May 2023 13:12:19 -0000 1.15 > +++ imsg_util.c 23 May 2023 13:16:09 -0000 > @@ -55,7 +55,7 @@ ibuf_new(const void *data, size_t len) > return (buf); > > if (data == NULL) { > - if (ibuf_advance(buf, len) == NULL) { > + if (ibuf_reserve(buf, len) == NULL) { > ibuf_free(buf); > return (NULL); > } > @@ -73,12 +73,6 @@ struct ibuf * > ibuf_static(void) > { > return ibuf_open(IKED_MSGBUF_MAX); > -} > - > -void * > -ibuf_advance(struct ibuf *buf, size_t len) > -{ > - return ibuf_reserve(buf, len); > } > > size_t >