Skip to content

Commit c77bd75

Browse files
committed
eep: fix incorrect initialization of password variables
Fixes #523 Fixes #532
1 parent c591ffc commit c77bd75

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/capture_eep.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,8 +725,8 @@ capture_eep_receive_v3(const u_char *pkt, uint32_t size)
725725
#endif
726726
hep_chunk_t payload_chunk;
727727
hep_chunk_t authkey_chunk;
728-
char *password;
729-
int password_len;
728+
char *password = NULL;
729+
int password_len = 0;
730730
unsigned char *payload = 0;
731731
uint32_t total_len, pos;
732732
char buffer[MAX_CAPTURE_LEN] ;
@@ -843,6 +843,10 @@ capture_eep_receive_v3(const u_char *pkt, uint32_t size)
843843
case CAPTURE_EEP_CHUNK_AUTH_KEY:
844844
memcpy(&authkey_chunk, (void*) buffer + pos, sizeof(authkey_chunk));
845845
password_len = ntohs(authkey_chunk.length) - sizeof(authkey_chunk);
846+
if (password_len <= 0) {
847+
pos += chunk_len;
848+
continue;
849+
}
846850
password = sng_malloc(password_len);
847851
memcpy(password, (void*) buffer + pos + sizeof(hep_chunk_t), password_len);
848852
break;
@@ -868,7 +872,7 @@ capture_eep_receive_v3(const u_char *pkt, uint32_t size)
868872
// Validate password
869873
if (eep_cfg.capt_srv_password != NULL) {
870874
// No password in packet
871-
if (strlen(password) == 0)
875+
if (!password ||strlen(password) == 0)
872876
return NULL;
873877
// Check password matches configured
874878
if (strcmp(password, eep_cfg.capt_srv_password) != 0)

0 commit comments

Comments
 (0)