Fix: refuse overwrite mode buffers with less than two subbuffers
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 May 2014 13:27:01 +0000 (09:27 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 May 2014 13:27:01 +0000 (09:27 -0400)
Fixes #793

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
libringbuffer/ring_buffer_backend.c

index 0d2cc6d0359af249e4c65e4cd4f0b9d0efbe2f0f..7d3a37809e73da27b25d43d8914ed285545075f7 100644 (file)
@@ -234,6 +234,12 @@ int channel_backend_init(struct channel_backend *chanb,
                return -EINVAL;
        if (!num_subbuf || (num_subbuf & (num_subbuf - 1)))
                return -EINVAL;
+       /*
+        * Overwrite mode buffers require at least 2 subbuffers per
+        * buffer.
+        */
+       if (config->mode == RING_BUFFER_OVERWRITE && num_subbuf < 2)
+               return -EINVAL;
 
        ret = subbuffer_id_check_index(config, num_subbuf);
        if (ret)
This page took 0.025828 seconds and 4 git commands to generate.