Skip to content
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

Add received message size check #532

Merged
merged 1 commit into from
Feb 4, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/bootstrap_server/bootstrap_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "Error in recvfrom(): %d\r\n", errno);
}
else if (numBytes >= MAX_PACKET_SIZE)
{
fprintf(stderr, "Received packet >= MAX_PACKET_SIZE\r\n");
}
else
{
char s[INET6_ADDRSTRLEN];
Expand Down
6 changes: 5 additions & 1 deletion examples/client/lwm2mclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
#include <errno.h>
#include <signal.h>

#define MAX_PACKET_SIZE 1024
#define MAX_PACKET_SIZE 2048
#define DEFAULT_SERVER_IPV6 "[::1]"
#define DEFAULT_SERVER_IPV4 "127.0.0.1"

Expand Down Expand Up @@ -1297,6 +1297,10 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "Error in recvfrom(): %d %s\r\n", errno, strerror(errno));
}
else if (numBytes >= MAX_PACKET_SIZE)
{
fprintf(stderr, "Received packet >= MAX_PACKET_SIZE\r\n");
}
else if (0 < numBytes)
{
char s[INET6_ADDRSTRLEN];
Expand Down
6 changes: 5 additions & 1 deletion examples/lightclient/lightclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ extern char * get_server_uri(lwm2m_object_t * objectP, uint16_t secObjInstID);
extern lwm2m_object_t * get_test_object(void);
extern void free_test_object(lwm2m_object_t * object);

#define MAX_PACKET_SIZE 1024
#define MAX_PACKET_SIZE 2048

int g_reboot = 0;
static int g_quit = 0;
Expand Down Expand Up @@ -514,6 +514,10 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "Error in recvfrom(): %d %s\r\n", errno, strerror(errno));
}
else if (numBytes >= MAX_PACKET_SIZE)
{
fprintf(stderr, "Received packet >= MAX_PACKET_SIZE\r\n");
}
else if (0 < numBytes)
{
connection_t * connP;
Expand Down
6 changes: 5 additions & 1 deletion examples/server/lwm2mserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#include "commandline.h"
#include "connection.h"

#define MAX_PACKET_SIZE 1024
#define MAX_PACKET_SIZE 2048

static int g_quit = 0;

Expand Down Expand Up @@ -1140,6 +1140,10 @@ int main(int argc, char *argv[])
{
fprintf(stderr, "Error in recvfrom(): %d\r\n", errno);
}
else if (numBytes >= MAX_PACKET_SIZE)
{
fprintf(stderr, "Received packet >= MAX_PACKET_SIZE\r\n");
}
else
{
char s[INET6_ADDRSTRLEN];
Expand Down