Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer overflow in ring.h #397

Open
jlama opened this issue Mar 29, 2024 · 0 comments
Open

Buffer overflow in ring.h #397

jlama opened this issue Mar 29, 2024 · 0 comments

Comments

@jlama
Copy link

jlama commented Mar 29, 2024

Hi,

While reviewing the ringbuffer code in rtapi/ring.h, I noticed a buffer overflow bug.

In stream_write:

if (n2) {
	memcpy(&(ring->buf[t->tail + n1]), src + n1, n2);
	rtapi_smp_wmb();
	rtapi_store_u32(&t->tail, (t->tail + n1 + n2) & h->size_mask);
}

The memcpy should be:

memcpy(ring->buf, src + n1, n2);

Also the memory barrier is useless (the atomic store will issue one anyway), but that's another story.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant