diff --git a/lib_log.c b/lib_log.c index 79667b45..7c8090e1 100644 --- a/lib_log.c +++ b/lib_log.c @@ -8,6 +8,8 @@ //#define MARS_DEBUGGING //#define IO_DEBUGGING +#define MAX_RESERVE PAGE_SIZE + #include "lib_log.h" void exit_logst(struct log_status *logst) @@ -178,6 +180,11 @@ void *log_reserve(struct log_status *logst, struct log_header *lh) int offset; int status; + if (unlikely(lh->l_len <= 0 || lh->l_len > MAX_RESERVE)) { + MARS_ERR("trying to write %d bytes, max allowed = %d\n", lh->l_len, (int)PAGE_SIZE); + goto err; + } + MARS_IO("reserving %d bytes at %lld\n", lh->l_len, logst->log_pos); mref = logst->log_mref;