From: Mathieu Desnoyers Date: Tue, 17 Aug 2010 22:23:21 +0000 (-0400) Subject: UST strncpy assert fix X-Git-Tag: v0.7~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=578e232ab4e234294d03fb7022863b45c801eaa1;p=ust.git UST strncpy assert fix fix off by one in strncpy and write asserts(). Shows only when the event reserved fits the exact end of buffer. Signed-off-by: Mathieu Desnoyers --- diff --git a/libust/buffers.h b/libust/buffers.h index 63449d6..9fedc48 100644 --- a/libust/buffers.h +++ b/libust/buffers.h @@ -522,7 +522,8 @@ static __inline__ int ust_buffers_write(struct ust_buffer *buf, size_t offset, size_t buf_offset = BUFFER_OFFSET(offset, buf->chan); assert(buf_offset < buf->chan->subbuf_size*buf->chan->subbuf_cnt); - assert(buf_offset + len < buf->chan->subbuf_size*buf->chan->subbuf_cnt); + assert(buf_offset + len + <= buf->chan->subbuf_size*buf->chan->subbuf_cnt); ust_buffers_do_copy(buf->buf_data + buf_offset, src, len); @@ -590,7 +591,8 @@ int ust_buffers_strncpy(struct ust_buffer *buf, size_t offset, const void *src, int terminated; assert(buf_offset < buf->chan->subbuf_size*buf->chan->subbuf_cnt); - assert(buf_offset + len < buf->chan->subbuf_size*buf->chan->subbuf_cnt); + assert(buf_offset + len + <= buf->chan->subbuf_size*buf->chan->subbuf_cnt); copied = ust_buffers_do_strncpy(buf->buf_data + buf_offset, src, len, &terminated);