UST strncpy assert fix
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 17 Aug 2010 22:23:21 +0000 (18:23 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Fri, 20 Aug 2010 04:39:50 +0000 (00:39 -0400)
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 <mathieu.desnoyers@efficios.com>
libust/buffers.h

index 63449d6c024194fca1341769083a55cdfb93ff4b..9fedc487f1847c65a707981016023c7c4ee9e655 100644 (file)
@@ -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);
This page took 0.024241 seconds and 4 git commands to generate.