-
-
Notifications
You must be signed in to change notification settings - Fork 268
Fix server crash when read a malformed replication segment #9055
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,13 +127,21 @@ namespace | |
|
|
||
| const string& getAtomString() | ||
| { | ||
| const auto pos = getInt32(); | ||
| const ULONG pos = static_cast<ULONG>(getInt32()); | ||
|
|
||
| if (pos >= m_atoms.getCount()) | ||
| malformed(); | ||
|
|
||
| return m_atoms[pos]; | ||
| } | ||
|
|
||
| const MetaString getAtomMetaName() | ||
| { | ||
| const auto pos = getInt32(); | ||
| const ULONG pos = static_cast<ULONG>(getInt32()); | ||
|
|
||
| if (pos >= m_atoms.getCount()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
| malformed(); | ||
|
|
||
| return m_atoms[pos]; | ||
| } | ||
|
|
||
|
|
@@ -154,7 +162,7 @@ namespace | |
| { | ||
| const auto length = getInt32(); | ||
|
|
||
| if (m_data + length > m_end) | ||
| if (length <= 0 || m_end - m_data < length) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd allow zero-length strings even if it looks impossible now. |
||
| malformed(); | ||
|
|
||
| const string str((const char*) m_data, length); | ||
|
|
@@ -164,7 +172,7 @@ namespace | |
|
|
||
| const UCHAR* getBinary(ULONG length) | ||
| { | ||
| if (m_data + length > m_end) | ||
| if (m_end - m_data < length) | ||
| malformed(); | ||
|
|
||
| const auto ptr = m_data; | ||
|
|
@@ -185,6 +193,9 @@ namespace | |
| void defineAtom() | ||
| { | ||
| const auto length = getByte(); | ||
| if (length <= 0) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
| malformed(); | ||
|
|
||
| const auto ptr = getBinary(length); | ||
| const MetaString name((const char*) ptr, length); | ||
| m_atoms.add(name); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer explicit checks with a signed
pos:if (pos < 0 || pos >= m_atoms.getCount())