projects
/
lttng-modules.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: handle writes of length 0
[lttng-modules.git]
/
lib
/
ringbuffer
/
ring_buffer_backend.c
diff --git
a/lib/ringbuffer/ring_buffer_backend.c
b/lib/ringbuffer/ring_buffer_backend.c
index 69ad2a709a1d8727862ab1e541438cc616c1f7a3..8c9d2b7c54e7b583e896fec159349b2336a0fb21 100644
(file)
--- a/
lib/ringbuffer/ring_buffer_backend.c
+++ b/
lib/ringbuffer/ring_buffer_backend.c
@@
-724,8
+724,9
@@
EXPORT_SYMBOL_GPL(__lib_ring_buffer_copy_to_user);
* @dest : destination address
* @len : destination's length
*
* @dest : destination address
* @len : destination's length
*
- *
return string's length
+ *
Return string's length, or -EINVAL on error.
* Should be protected by get_subbuf/put_subbuf.
* Should be protected by get_subbuf/put_subbuf.
+ * Destination length should be at least 1 to hold '\0'.
*/
int lib_ring_buffer_read_cstr(struct lib_ring_buffer_backend *bufb, size_t offset,
void *dest, size_t len)
*/
int lib_ring_buffer_read_cstr(struct lib_ring_buffer_backend *bufb, size_t offset,
void *dest, size_t len)
@@
-741,6
+742,8
@@
int lib_ring_buffer_read_cstr(struct lib_ring_buffer_backend *bufb, size_t offse
offset &= chanb->buf_size - 1;
index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
orig_offset = offset;
offset &= chanb->buf_size - 1;
index = (offset & (chanb->subbuf_size - 1)) >> PAGE_SHIFT;
orig_offset = offset;
+ if (unlikely(!len))
+ return -EINVAL;
for (;;) {
id = bufb->buf_rsb.id;
sb_bindex = subbuffer_id_get_index(config, id);
for (;;) {
id = bufb->buf_rsb.id;
sb_bindex = subbuffer_id_get_index(config, id);
This page took
0.024468 seconds
and
4
git commands to generate.