Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
acc1c838
Unverified
Commit
acc1c838
authored
Sep 25, 2019
by
Dennis Jenkins
Committed by
GitHub
Sep 25, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #609 from win32asm/master
Fix access beyond passed buffer when constructing RawBuffer
parents
0c21c854
37e3a3a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
src/common/stream.cc
src/common/stream.cc
+2
-2
tests/stream_test.cc
tests/stream_test.cc
+21
-1
No files found.
src/common/stream.cc
View file @
acc1c838
...
...
@@ -34,8 +34,8 @@ RawBuffer::RawBuffer(const char* data, size_t length, bool isDetached)
,
length_
(
length
)
,
isDetached_
(
isDetached
)
{
data_
.
resize
(
length_
+
1
);
data_
.
assign
(
data
,
length_
+
1
);
// input may come not from a ZTS - copy only length_ characters.
data_
.
assign
(
data
,
length_
);
}
RawBuffer
RawBuffer
::
detach
(
size_t
fromIndex
)
...
...
tests/stream_test.cc
View file @
acc1c838
...
...
@@ -29,7 +29,7 @@ TEST(stream, test_buffer)
RawBuffer
buffer4
=
buffer3
.
detach
(
0
);
ASSERT_EQ
(
buffer4
.
size
(),
0u
);
ASSERT_EQ
(
buffer4
.
isDetached
(),
false
);
ASSERT_THROW
(
buffer1
.
detach
(
2
*
len
);,
std
::
range_error
);
}
...
...
@@ -55,3 +55,23 @@ TEST(stream, test_file_buffer)
std
::
remove
(
fileName
);
}
TEST
(
stream
,
test_dyn_buffer
)
{
DynamicStreamBuf
buf
(
128
);
{
std
::
ostream
os
(
&
buf
);
for
(
unsigned
i
=
0
;
i
<
128
;
++
i
)
{
os
<<
"A"
;
}
}
auto
rawbuf
=
buf
.
buffer
();
ASSERT_EQ
(
rawbuf
.
size
(),
128u
);
ASSERT_EQ
(
rawbuf
.
isDetached
(),
false
);
ASSERT_EQ
(
rawbuf
.
data
().
size
(),
128u
);
ASSERT_EQ
(
strlen
(
rawbuf
.
data
().
c_str
()),
128u
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment