diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-02-09 14:39:57 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-02-09 14:39:57 +0000 |
commit | c00e19926dc4090180b78588335af1b8433aead4 (patch) | |
tree | 41cb651db11969c8d570b10a4578bc5095f54f4f /usr.sbin/ospfd/buffer.c | |
parent | 8b5afed2325e826f9df13061f49c84349c0f7b8f (diff) |
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@
Diffstat (limited to 'usr.sbin/ospfd/buffer.c')
-rw-r--r-- | usr.sbin/ospfd/buffer.c | 12 |
1 files changed, 11 insertions, 1 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) { |