Skip to content

Buffer overflow fixes for radiotap. #322

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

Merged
merged 3 commits into from
Jan 8, 2019
Merged
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
6 changes: 5 additions & 1 deletion include/tins/utils/radiotap_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ class RadioTapParser {
RadioTap::option current_option();

/**
* Gets the pointer at which the current option is located
* \brief Gets the pointer at which the current option is located
*
* A past-the-end pointer may be returned in case of malformed input or
* end of data. Its validity must be checked (e.g. using
* \ref RadioTapParser.has_fields) before dereference.
*/
const uint8_t* current_option_ptr() const;

Expand Down
5 changes: 1 addition & 4 deletions src/utils/radiotap_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const RadioTapParser::FieldMetadata RadioTapParser::RADIOTAP_METADATA[] = {
};

const uint32_t RadioTapParser::MAX_RADIOTAP_FIELD = sizeof(RADIOTAP_METADATA) /
sizeof(FieldMetadata) + 1;
sizeof(FieldMetadata);

#if TINS_IS_LITTLE_ENDIAN
TINS_BEGIN_PACK
Expand Down Expand Up @@ -135,9 +135,6 @@ void align_buffer(const uint8_t* buffer_start, const uint8_t*& buffer, uint32_t
uint32_t offset = (buffer - buffer_start) & (n - 1);
if (offset) {
offset = n - offset;
if (TINS_UNLIKELY(offset > size)) {
throw malformed_packet();
}
buffer += offset;
}
}
Expand Down