Reformat
This commit is contained in:
16
mud.c
16
mud.c
@@ -4,19 +4,21 @@
|
|||||||
#define __APPLE_USE_RFC_3542
|
#define __APPLE_USE_RFC_3542
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ifaddrs.h>
|
#include <ifaddrs.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
#include <time.h>
|
#include <netinet/in.h>
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
|
||||||
@@ -975,13 +977,14 @@ mud_packet_check_size(unsigned char *data, size_t size)
|
|||||||
if (size <= MUD_PACKET_SIZE(0))
|
if (size <= MUD_PACKET_SIZE(0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
const size_t sizes[] = {
|
const size_t sizes[] = {
|
||||||
[mud_kiss] = MUD_PACKET_SIZE(sizeof(packet->data.kiss)),
|
[mud_kiss] = MUD_PACKET_SIZE(sizeof(packet->data.kiss)),
|
||||||
[mud_stat] = MUD_PACKET_SIZE(sizeof(packet->data.stat)),
|
[mud_stat] = MUD_PACKET_SIZE(sizeof(packet->data.stat)),
|
||||||
[mud_keyx] = MUD_PACKET_SIZE(sizeof(packet->data.public)),
|
[mud_keyx] = MUD_PACKET_SIZE(sizeof(packet->data.public)),
|
||||||
[mud_mtux] = MUD_PACKET_SIZE(sizeof(packet->data.mtu)),
|
[mud_mtux] = MUD_PACKET_SIZE(sizeof(packet->data.mtu)),
|
||||||
[mud_bakx] = MUD_PACKET_SIZE(sizeof(packet->data.backup)),
|
[mud_bakx] = MUD_PACKET_SIZE(sizeof(packet->data.backup)),
|
||||||
};
|
}; // clang-format on
|
||||||
|
|
||||||
return (packet->hdr.code >= sizeof(sizes)) ||
|
return (packet->hdr.code >= sizeof(sizes)) ||
|
||||||
(sizes[packet->hdr.code] != size);
|
(sizes[packet->hdr.code] != size);
|
||||||
@@ -999,8 +1002,7 @@ mud_packet_check(struct mud *mud, unsigned char *data, size_t size)
|
|||||||
.size = MUD_MAC_SIZE,
|
.size = MUD_MAC_SIZE,
|
||||||
},
|
},
|
||||||
.ad = {
|
.ad = {
|
||||||
.data = data,
|
.data = data, .size = size - MUD_MAC_SIZE,
|
||||||
.size = size - MUD_MAC_SIZE,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user