From 394021fd916852fb59e3c5ab89f00e116294e1f7 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 19 Mar 2008 10:56:51 +0000 Subject: Fix two bugs introduced in conversion to FreeBSD source tree: Off by one error in length calcuation of string records. Don't attempt to free stack variable. --- usr.sbin/fifolog/lib/fifolog_int.c | 1 - usr.sbin/fifolog/lib/fifolog_write_poll.c | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/fifolog/lib/fifolog_int.c b/usr.sbin/fifolog/lib/fifolog_int.c index 9093174..158c613 100644 --- a/usr.sbin/fifolog/lib/fifolog_int.c +++ b/usr.sbin/fifolog/lib/fifolog_int.c @@ -192,7 +192,6 @@ fifolog_int_close(struct fifolog_file **ff) free(f->zs); if (f->recbuf != NULL) free(f->recbuf); - free(f); } static void diff --git a/usr.sbin/fifolog/lib/fifolog_write_poll.c b/usr.sbin/fifolog/lib/fifolog_write_poll.c index 86615aa..afff022 100644 --- a/usr.sbin/fifolog/lib/fifolog_write_poll.c +++ b/usr.sbin/fifolog/lib/fifolog_write_poll.c @@ -93,6 +93,7 @@ fifolog_write_close(struct fifolog_writer *f) CHECK_OBJ_NOTNULL(f, FIFOLOG_WRITER_MAGIC); fifolog_int_close(&f->ff); + free(f->ff); if (f->ibuf != NULL) free(f->ibuf); free(f); @@ -317,13 +318,12 @@ fifolog_write_bytes(struct fifolog_writer *f, uint32_t id, time_t now, const voi assert(!(id & (FIFOLOG_TIMESTAMP|FIFOLOG_LENGTH))); assert(ptr != NULL); + p = ptr; if (len == 0) { - len = strlen(ptr); + len = strlen(ptr) + 1; l = 4 + len; /* id */ - p = ptr; } else { assert(len <= 255); - p = ptr; id |= FIFOLOG_LENGTH; l = 5 + len; /* id + len */ } @@ -336,7 +336,7 @@ fifolog_write_bytes(struct fifolog_writer *f, uint32_t id, time_t now, const voi assert(l < f->ibufsize); - /* Wait until there is sufficient space without the lock */ + /* Return if there is not enough space */ if (f->iptr + l > f->ibuf + f->ibufsize) return (0); -- cgit v1.1