summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2005-02-09 14:39:56 +0000
committerclaudio <claudio@openbsd.org>2005-02-09 14:39:56 +0000
commita3f29b4d28f741dc8917464f2e7ede0ff198effa (patch)
treeb3bb6297da1f3eb86403c6cbcdcfc29c1180e178
parentPrint the neighbor address and not the local interface address in (diff)
downloadwireguard-openbsd-a3f29b4d28f741dc8917464f2e7ede0ff198effa.tar.xz
wireguard-openbsd-a3f29b4d28f741dc8917464f2e7ede0ff198effa.zip
Add buf_seek() as buf_reserve() fails if a buf_add()/buf_reserve() is
called afterwards as it may realloc() the buffer and so the returned pointer is bogus. Needed by the upcomming originate LSA code. OK henning@
-rw-r--r--usr.sbin/ospfd/buffer.c12
-rw-r--r--usr.sbin/ospfd/ospfd.h3
2 files changed, 13 insertions, 2 deletions
diff --git a/usr.sbin/ospfd/buffer.c b/usr.sbin/ospfd/buffer.c
index 42d160499ed..41693565a10 100644
--- a/usr.sbin/ospfd/buffer.c
+++ b/usr.sbin/ospfd/buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buffer.c,v 1.2 2005/02/01 21:25:18 claudio Exp $ */
+/* $OpenBSD: buffer.c,v 1.3 2005/02/09 14:39:56 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -111,6 +111,16 @@ buf_reserve(struct buf *buf, size_t len)
return (b);
}
+void *
+buf_seek(struct buf *buf, size_t pos, size_t len)
+{
+ /* only allowed to seek in already written parts */
+ if (pos + len > buf->wpos)
+ return (NULL);
+
+ return (buf->buf + pos);
+}
+
int
buf_close(struct msgbuf *msgbuf, struct buf *buf)
{
diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h
index 6d954ad2442..78e114c50ab 100644
--- a/usr.sbin/ospfd/ospfd.h
+++ b/usr.sbin/ospfd/ospfd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfd.h,v 1.5 2005/02/07 05:51:00 david Exp $ */
+/* $OpenBSD: ospfd.h,v 1.6 2005/02/09 14:39:56 claudio Exp $ */
/*
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
@@ -367,6 +367,7 @@ struct buf *buf_open(size_t);
struct buf *buf_dynamic(size_t, size_t);
int buf_add(struct buf *, void *, size_t);
void *buf_reserve(struct buf *, size_t);
+void *buf_seek(struct buf *, size_t, size_t);
int buf_close(struct msgbuf *, struct buf *);
int buf_write(int, struct buf *);
void buf_free(struct buf *);