mirror of
https://github.com/mfontanini/libtins
synced 2026-01-29 04:54:28 +01:00
Fix compilation warnings on Windows x64.
This commit is contained in:
@@ -387,8 +387,9 @@ namespace Crypto {
|
||||
|
||||
template<typename ForwardIterator>
|
||||
RC4Key::RC4Key(ForwardIterator start, ForwardIterator end) {
|
||||
for(size_t i = 0; i < data_size; ++i)
|
||||
data[i] = i;
|
||||
for(size_t i = 0; i < data_size; ++i) {
|
||||
data[i] = static_cast<uint8_t>(i);
|
||||
}
|
||||
size_t j = 0;
|
||||
ForwardIterator iter = start;
|
||||
for(size_t i = 0; i < data_size; ++i) {
|
||||
|
||||
@@ -891,7 +891,7 @@ void class_option_data2option(InputIterator start, InputIterator end,
|
||||
uint16_t uint16_t_buffer;
|
||||
while(start != end) {
|
||||
buffer.resize(buffer.size() + sizeof(uint16_t) + start->size());
|
||||
uint16_t_buffer = Endian::host_to_be<uint16_t>(start->size());
|
||||
uint16_t_buffer = Endian::host_to_be(static_cast<uint16_t>(start->size()));
|
||||
std::memcpy(&buffer[index], &uint16_t_buffer, sizeof(uint16_t));
|
||||
index += sizeof(uint16_t);
|
||||
std::copy(start->begin(), start->end(), buffer.begin() + index);
|
||||
|
||||
@@ -144,7 +144,9 @@ protected:
|
||||
/**
|
||||
* \brief Getter for the control ta additional fields size.
|
||||
*/
|
||||
uint32_t controlta_size() const { return _taddr.size() + sizeof(ieee80211_header); }
|
||||
uint32_t controlta_size() const {
|
||||
return static_cast<uint32_t>(_taddr.size() + sizeof(ieee80211_header));
|
||||
}
|
||||
|
||||
uint32_t write_ext_header(uint8_t *buffer, uint32_t total_sz);
|
||||
private:
|
||||
|
||||
@@ -246,8 +246,10 @@ protected:
|
||||
uint32_t write_ext_header(uint8_t *buffer, uint32_t total_sz);
|
||||
|
||||
uint32_t data_frame_size() {
|
||||
return Dot11::header_size() + sizeof(_ext_header) +
|
||||
((from_ds() && to_ds()) ? _addr4.size() : 0);
|
||||
return static_cast<uint32_t>(
|
||||
Dot11::header_size() + sizeof(_ext_header) +
|
||||
((from_ds() && to_ds()) ? _addr4.size() : 0)
|
||||
);
|
||||
}
|
||||
private:
|
||||
ExtendedHeader _ext_header;
|
||||
|
||||
@@ -180,6 +180,17 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Exception thrown when a payload is too large to fit
|
||||
* into a PDUOption.
|
||||
*/
|
||||
class option_payload_too_large : public std::exception {
|
||||
public:
|
||||
const char *what() const throw() {
|
||||
return "Option payload too large";
|
||||
}
|
||||
};
|
||||
|
||||
} // Tins
|
||||
|
||||
#endif // TINS_EXCEPTIONS_H
|
||||
|
||||
@@ -312,7 +312,7 @@ public:
|
||||
* \param data The option's data(if any).
|
||||
*/
|
||||
PDUOption(option_type opt = option_type(), size_t length = 0, const data_type *data = 0)
|
||||
: option_(opt), size_(length) {
|
||||
: option_(opt), size_(static_cast<uint16_t>(length)) {
|
||||
set_payload_contents(data, data + (data ? length : 0));
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ public:
|
||||
*/
|
||||
template<typename ForwardIterator>
|
||||
PDUOption(option_type opt, ForwardIterator start, ForwardIterator end)
|
||||
: option_(opt), size_(std::distance(start, end)) {
|
||||
: option_(opt), size_(static_cast<uint16_t>(std::distance(start, end))) {
|
||||
set_payload_contents(start, end);
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ public:
|
||||
* \param end The end of the option data.
|
||||
*/
|
||||
template<typename ForwardIterator>
|
||||
PDUOption(option_type opt, size_t length, ForwardIterator start, ForwardIterator end)
|
||||
PDUOption(option_type opt, uint16_t length, ForwardIterator start, ForwardIterator end)
|
||||
: option_(opt), size_(length) {
|
||||
set_payload_contents(start, end);
|
||||
}
|
||||
@@ -492,7 +492,11 @@ public:
|
||||
private:
|
||||
template<typename ForwardIterator>
|
||||
void set_payload_contents(ForwardIterator start, ForwardIterator end) {
|
||||
real_size_ = std::distance(start, end);
|
||||
size_t total_size = std::distance(start, end);
|
||||
if (total_size > std::numeric_limits<uint16_t>::max()) {
|
||||
throw option_payload_too_large();
|
||||
}
|
||||
real_size_ = static_cast<uint16_t>(total_size);
|
||||
if(real_size_ <= small_buffer_size) {
|
||||
std::copy(
|
||||
start,
|
||||
|
||||
@@ -240,7 +240,7 @@ public:
|
||||
* \param option The option to be added.
|
||||
*/
|
||||
void add_tag(tag &&option) {
|
||||
_tags_size += option.data_size() + sizeof(uint16_t) * 2;
|
||||
_tags_size += static_cast<uint16_t>(option.data_size() + sizeof(uint16_t) * 2);
|
||||
_tags.push_back(std::move(option));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Tins {
|
||||
* \return uint32_t containing the payload size.
|
||||
*/
|
||||
uint32_t payload_size() const {
|
||||
return _payload.size();
|
||||
return static_cast<uint32_t>(_payload.size());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +184,7 @@ namespace Tins {
|
||||
*/
|
||||
template<typename T>
|
||||
T to() const {
|
||||
return T(&_payload[0], _payload.size());
|
||||
return T(&_payload[0], static_cast<uint32_t>(_payload.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user