summaryrefslogtreecommitdiffstats
path: root/usr.sbin/fifolog/lib
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2008-03-19 10:56:51 +0000
committerphk <phk@FreeBSD.org>2008-03-19 10:56:51 +0000
commit394021fd916852fb59e3c5ab89f00e116294e1f7 (patch)
tree662c03344974dcf26c784b73457717f23bb6b17f /usr.sbin/fifolog/lib
parentd818a8db6839fadf3aba5d6d4a2bb79483200ba3 (diff)
downloadFreeBSD-src-394021fd916852fb59e3c5ab89f00e116294e1f7.zip
FreeBSD-src-394021fd916852fb59e3c5ab89f00e116294e1f7.tar.gz
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.
Diffstat (limited to 'usr.sbin/fifolog/lib')
-rw-r--r--usr.sbin/fifolog/lib/fifolog_int.c1
-rw-r--r--usr.sbin/fifolog/lib/fifolog_write_poll.c8
2 files changed, 4 insertions, 5 deletions
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);
OpenPOWER on IntegriCloud