1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-27 12:14:26 +01:00

Fixed some compilation errors/warnings and bugs when using Big Endian architectures.

This commit is contained in:
Matias Fontanini
2013-09-24 00:34:14 -03:00
parent 9cbac6b044
commit c4e6a7c0d6
24 changed files with 217 additions and 183 deletions

View File

@@ -32,6 +32,7 @@
#include <cassert>
#endif
#include <stdexcept>
#include <iostream> // borrame
#include "eapol.h"
#include "rsn_information.h"
#include "exceptions.h"
@@ -56,7 +57,12 @@ EAPOL *EAPOL::from_bytes(const uint8_t *buffer, uint32_t total_sz) {
if(total_sz < sizeof(eapolhdr))
throw malformed_packet();
const eapolhdr *ptr = (const eapolhdr*)buffer;
total_sz = std::min(total_sz, (uint32_t)ptr->length);
uint32_t data_len = Endian::be_to_host<uint16_t>(ptr->length);
// at least 4 for fields always present
total_sz = std::min(
total_sz,
data_len + 4
);
switch(ptr->type) {
case RC4:
return new Tins::RC4EAPOL(buffer, total_sz);