From: claudio Date: Tue, 12 Dec 2023 15:52:58 +0000 (+0000) Subject: ibuf_getdata() abuses the rpos from the ibuf. This is no longer allowed X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c45f3621a4984cafb12365fce0a55d4457d95cd4;p=openbsd ibuf_getdata() abuses the rpos from the ibuf. This is no longer allowed and breaks because ibuf_seek() now uses rpos itself. Now this is just ibuf_get_ibuf() with an extra allocation done. OK tobhe@ tb@ --- diff --git a/sbin/iked/imsg_util.c b/sbin/iked/imsg_util.c index bf97af6f885..a008872cd38 100644 --- a/sbin/iked/imsg_util.c +++ b/sbin/iked/imsg_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg_util.c,v 1.21 2023/07/18 15:07:41 claudio Exp $ */ +/* $OpenBSD: imsg_util.c,v 1.22 2023/12/12 15:52:58 claudio Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter @@ -80,13 +80,12 @@ ibuf_length(struct ibuf *buf) struct ibuf * ibuf_getdata(struct ibuf *buf, size_t len) { - void *data; + struct ibuf tmp; - if ((data = ibuf_seek(buf, buf->rpos, len)) == NULL) + if (ibuf_get_ibuf(buf, len, &tmp) == -1) return (NULL); - buf->rpos += len; - return (ibuf_new(data, len)); + return (ibuf_new(ibuf_data(&tmp), ibuf_size(&tmp))); } struct ibuf *