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

base: apply StreamBuffer::grow patch to StreamDevice. #28

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ ARG AREA_DETECTOR_VERSION
ARG MOTOR_VERSION

WORKDIR ${EPICS_MODULES_PATH}

COPY patches/streambuffer-grow.patch .
COPY install_modules.sh .
RUN ./install_modules.sh

COPY nanohttp_stream.patch .
COPY patches/nanohttp_stream.patch .
COPY install_area_detector.sh .
RUN ./install_area_detector.sh

Expand Down
4 changes: 3 additions & 1 deletion base/install_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ EPICS_BASE = ${EPICS_BASE_PATH}
CALC = ${EPICS_MODULES_PATH}/calc
"

install_github_module paulscherrerinstitute StreamDevice STREAM $STREAMDEVICE_VERSION "
download_github_module paulscherrerinstitute StreamDevice $STREAMDEVICE_VERSION
git apply --directory StreamDevice ${EPICS_MODULES_PATH}/streambuffer-grow.patch
install_module StreamDevice STREAM "
EPICS_BASE = ${EPICS_BASE_PATH}

ASYN = ${EPICS_MODULES_PATH}/asyn
Expand Down
File renamed without changes.
27 changes: 27 additions & 0 deletions base/patches/streambuffer-grow.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From https://github.com/paulscherrerinstitute/StreamDevice/pull/96
From 34cf0476915ac7b6770af88ab02f836b6ffb710d Mon Sep 17 00:00:00 2001
From: sudastelaro <[email protected]>
Date: Fri, 27 Oct 2023 12:54:27 -0300
Subject: [PATCH] Clear the right number of bytes in StreamBuffer

The wrong number of bytes was being cleared in StreamBuffer::grow. That
could lead to memory access out of bounds.
---
src/StreamBuffer.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/StreamBuffer.cc b/src/StreamBuffer.cc
index fdba24f..c7d53b4 100644
--- a/src/StreamBuffer.cc
+++ b/src/StreamBuffer.cc
@@ -144,7 +144,7 @@ grow(size_t minsize)
// just move contents to start of buffer and clear end
// to avoid reallocation
memmove(buffer, buffer+offs, len);
- memset(buffer+len, 0, offs);
+ memset(buffer+len, 0, cap-len);
offs = 0;
return;
}
--
2.34.1