- ARP and ICMP double free bug fixed

- Memory leak caused by packet drop fixed
- MemoryPool warns about possible double free
This commit is contained in:
Wiesner András 2023-02-25 13:46:47 +01:00
parent 11d7431d96
commit 40d6417ae4
8 changed files with 11 additions and 7 deletions

View File

@ -62,6 +62,7 @@ void ethinf_receive(EthInterface *intf, const RawPckt *rawPckt) {
if (pushOK) {
ETHLIB_OS_SEM_POST(&intf->rxSem);
} else {
dynmem_free(rawPckt->payload);
ERROR("Input queue full, packet dropped!\n");
}
}

View File

@ -153,6 +153,10 @@ void mp_free(MP *mp, const uint8_t *p) {
if (success) {
mp_join_free_blocks(mp);
}
if (!success) {
WARNING("Possible double free!\n");
}
}
void mp_report(MP *mp) {

View File

@ -50,7 +50,7 @@ RawPckt mq_top(MsgQueue * mq) {
}
void mq_pop(MsgQueue * mq) {
if (mq_avail(mq) > 0) { // if there's something to pop
if (mq_avail(mq) > 0) { // if there's anything to pop
mq->readIdx = MQ_NEXT(mq->size, mq->readIdx);
}
}

View File

@ -90,6 +90,8 @@ void packsieve_input(PcktSieve *sieve, const RawPckt *rawPckt) {
lastHeader = header;
} while ((ownClass != 0) && lastHeader->props.validityOK);
lastHeader->next = NULL;
// ------------------------------------
if (!lastHeader->props.validityOK) { // if packet is not valid, then drop

View File

@ -77,7 +77,7 @@ void arp_send(const ConnBlock * connBlock, const ArpProps * props) {
ethinf_transmit(connBlock->sieve->intf, &rpckt);
// release transmit buffer
dynmem_free(txBuf);
//dynmem_free(txBuf);
}
void arp_print_report(const ConnBlock *connBlock) {

View File

@ -48,7 +48,7 @@ static int icmp_recv_cb(const Pckt * pckt, PcktSieveLayerTag tag) {
pckt_assemble(&raw, pckt);
// release headers
pckthdr_chain_free(pckt->header);
//pckthdr_chain_free(pckt->header);
ethinf_transmit(intf, &raw);
}

View File

@ -253,8 +253,6 @@ void dhcp_request(ip4_addr reqAddr, ip4_addr dhcpServerAddr) {
}
static void dhcp_process(DhcpProps *props, DhcpOption *opts) {
MSG("ENTER\n");
ETHLIB_OS_MTX_LOCK(&s.procMtx); // LOCK!
switch (s.state) {
@ -323,8 +321,6 @@ static void dhcp_process(DhcpProps *props, DhcpOption *opts) {
}
ETHLIB_OS_MTX_UNLOCK(&s.procMtx); // RELEASE!
MSG("EXIT\n");
}
static int dhcp_resp_cb(const Pckt *pckt, PcktSieveLayerTag tag) {

View File

@ -32,6 +32,7 @@
#endif
#define ERROR(...) MSG(__VA_ARGS__)
#define WARNING(...) MSG(__VA_ARGS__)
#define INFO(...) MSG(__VA_ARGS__)
#define SNPRINTF(s,n,...) snprintf(s,n,__VA_ARGS__)