Skip to content

Commit bfa1432

Browse files
committed
typo fix and check if tx packets larger than allowed
1 parent 51ae555 commit bfa1432

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

include/cblk/csp_if_cblk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef struct __attribute__((packed))
3333
#define CCSDS_FRAME_LEN 223
3434
#define CBLK_DATA_LEN (CCSDS_FRAME_LEN-sizeof(cblk_hdr_t))
3535
#define CRYPTO_PREAMP 16 /* crypto_secretbox_BOXZEROBYTES */
36-
#define CRYPTO_POSTAMP (16+9) /* 16 zero fill + NOUNCE_SIZE */
36+
#define CRYPTO_POSTAMP (16+9) /* 16 zero fill + NONCE_SIZE */
3737
#define CRYPTO_MAC_SIZE 16
3838
/* ccsds frame index is 4 bits */
3939
#define CBLK_MAX_FRAMES_PER_PACKET 15

src/csp_if_cblk.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "cblk/csp_if_cblk.h"
22

3-
#include <math.h>
43
#include <stdio.h>
54
#include <endian.h>
65
#include <csp/crypto/csp_hmac.h>
@@ -84,6 +83,14 @@ int csp_if_cblk_tx(csp_iface_t * iface, uint16_t via, csp_packet_t *packet, int
8483
uint16_t bytes_remain = packet->frame_length;
8584
uint8_t num_frames = num_ccsds_from_csp(packet->frame_length);
8685

86+
if(num_frames == 0) {
87+
csp_buffer_free(packet);
88+
if (_cblk_tx_debug >= 1) {
89+
printf("Packet too large to send: %u bytes\n", packet->frame_length);
90+
}
91+
return CSP_ERR_INVAL;
92+
}
93+
8794
ifdata->cblk_tx_lock(iface);
8895

8996
for (int8_t frame_cnt = 0; frame_cnt < num_frames; frame_cnt++) {

0 commit comments

Comments
 (0)