Skip to content

Commit

Permalink
bin interface processing: add check for min length
Browse files Browse the repository at this point in the history
(cherry picked from commit 4efeba5)

Conflicts:
	bin_interface.c
  • Loading branch information
liviuchircu committed Mar 5, 2015
1 parent aeb3519 commit bb53e6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions bin_interface.c
Expand Up @@ -363,8 +363,9 @@ static void bin_receive_loop(void)
}

rcv_end = rcv_buf + rcv_bytes;
if (rcv_bytes < MIN_UDP_PACKET) {
LM_DBG("probing packet received len = %d\n", rcv_bytes);

if (rcv_bytes < MIN_BIN_PACKET_SIZE) {
LM_INFO("received invalid packet: len = %d\n", rcv_bytes);
continue;
}

Expand Down
2 changes: 2 additions & 0 deletions bin_interface.h
Expand Up @@ -34,6 +34,8 @@
#define LEN_FIELD_SIZE sizeof(int)
#define CMD_FIELD_SIZE sizeof(int)
#define HEADER_SIZE (BIN_PACKET_MARKER_SIZE + CRC_FIELD_SIZE)
#define MIN_BIN_PACKET_SIZE \
(HEADER_SIZE + LEN_FIELD_SIZE + CMD_FIELD_SIZE + 2) /* e.g. >tm<.so */

#define is_valid_bin_packet(_p) \
(memcmp(_p, BIN_PACKET_MARKER, BIN_PACKET_MARKER_SIZE) == 0)
Expand Down

0 comments on commit bb53e6c

Please sign in to comment.