|
1 | 1 | #include <iostream> |
2 | 2 | #include <sstream> |
| 3 | +#include <cstring> |
3 | 4 |
|
4 | 5 | #include <IPv6Layer.h> |
5 | 6 | #include <IPv4Layer.h> |
@@ -87,11 +88,11 @@ struct Cookie { |
87 | 88 | #define htole16 |
88 | 89 | #endif |
89 | 90 |
|
90 | | -#define V64BE(list, index, data) (*(uint64_t *) &(list)[index]) = htobe64(data) |
91 | | -#define V64(list, index, data) (*(uint64_t *) &(list)[index]) = htole64(data) |
92 | | -#define V32(list, index, data) (*(uint32_t *) &(list)[index]) = htole32(data) |
93 | | -#define V16(list, index, data) (*(uint16_t *) &(list)[index]) = htole16(data) |
94 | | -#define V8(list, index, data) (*(uint8_t *) &(list)[index]) = data |
| 91 | +#define V64BE(list, index, data) {uint64_t temp = htobe64(data); std::memcpy(&(list)[index], &temp, sizeof(uint64_t));} |
| 92 | +#define V64(list, index, data) {uint64_t temp = htole64(data); std::memcpy(&(list)[index], &temp, sizeof(uint64_t));} |
| 93 | +#define V32(list, index, data) {uint32_t temp = htole32(data); std::memcpy(&(list)[index], &temp, sizeof(uint32_t));} |
| 94 | +#define V16(list, index, data) {uint16_t temp = htole16(data); std::memcpy(&(list)[index], &temp, sizeof(uint16_t));} |
| 95 | +#define V8(list, index, data) {uint8_t temp = data; std::memcpy(&(list)[index], &temp, sizeof(uint8_t));} |
95 | 96 |
|
96 | 97 | #define CHECK_RET(value) { int ret = (value); if(ret != RETURN_SUCCESS) return ret;} |
97 | 98 | #define CHECK_RUNNING() if (!running) return RETURN_STOP |
@@ -937,7 +938,8 @@ int Exploit::stage2() { |
937 | 938 | if (option[0] != 1) return false; // type 1 is ICMPv6NDOptSrcLLAddr |
938 | 939 | if (option[1] > 1) { |
939 | 940 | auto *self = (Exploit *) cookie; |
940 | | - self->pppoe_softc_list = htole64(*(uint64_t * )(option + 3)); |
| 941 | + std::memcpy(&self->pppoe_softc_list, option + 3, sizeof(uint64_t)); |
| 942 | + self->pppoe_softc_list = htole64(self->pppoe_softc_list); |
941 | 943 | return true; // length > 1 |
942 | 944 | } |
943 | 945 | return false; |
|
0 commit comments