- 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:
parent
11d7431d96
commit
40d6417ae4
@ -62,6 +62,7 @@ void ethinf_receive(EthInterface *intf, const RawPckt *rawPckt) {
|
|||||||
if (pushOK) {
|
if (pushOK) {
|
||||||
ETHLIB_OS_SEM_POST(&intf->rxSem);
|
ETHLIB_OS_SEM_POST(&intf->rxSem);
|
||||||
} else {
|
} else {
|
||||||
|
dynmem_free(rawPckt->payload);
|
||||||
ERROR("Input queue full, packet dropped!\n");
|
ERROR("Input queue full, packet dropped!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,6 +153,10 @@ void mp_free(MP *mp, const uint8_t *p) {
|
|||||||
if (success) {
|
if (success) {
|
||||||
mp_join_free_blocks(mp);
|
mp_join_free_blocks(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!success) {
|
||||||
|
WARNING("Possible double free!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mp_report(MP *mp) {
|
void mp_report(MP *mp) {
|
||||||
|
@ -50,7 +50,7 @@ RawPckt mq_top(MsgQueue * mq) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mq_pop(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);
|
mq->readIdx = MQ_NEXT(mq->size, mq->readIdx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,8 @@ void packsieve_input(PcktSieve *sieve, const RawPckt *rawPckt) {
|
|||||||
lastHeader = header;
|
lastHeader = header;
|
||||||
} while ((ownClass != 0) && lastHeader->props.validityOK);
|
} while ((ownClass != 0) && lastHeader->props.validityOK);
|
||||||
|
|
||||||
|
lastHeader->next = NULL;
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
|
||||||
if (!lastHeader->props.validityOK) { // if packet is not valid, then drop
|
if (!lastHeader->props.validityOK) { // if packet is not valid, then drop
|
||||||
|
@ -77,7 +77,7 @@ void arp_send(const ConnBlock * connBlock, const ArpProps * props) {
|
|||||||
ethinf_transmit(connBlock->sieve->intf, &rpckt);
|
ethinf_transmit(connBlock->sieve->intf, &rpckt);
|
||||||
|
|
||||||
// release transmit buffer
|
// release transmit buffer
|
||||||
dynmem_free(txBuf);
|
//dynmem_free(txBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void arp_print_report(const ConnBlock *connBlock) {
|
void arp_print_report(const ConnBlock *connBlock) {
|
||||||
|
@ -48,7 +48,7 @@ static int icmp_recv_cb(const Pckt * pckt, PcktSieveLayerTag tag) {
|
|||||||
pckt_assemble(&raw, pckt);
|
pckt_assemble(&raw, pckt);
|
||||||
|
|
||||||
// release headers
|
// release headers
|
||||||
pckthdr_chain_free(pckt->header);
|
//pckthdr_chain_free(pckt->header);
|
||||||
|
|
||||||
ethinf_transmit(intf, &raw);
|
ethinf_transmit(intf, &raw);
|
||||||
}
|
}
|
||||||
|
@ -253,8 +253,6 @@ void dhcp_request(ip4_addr reqAddr, ip4_addr dhcpServerAddr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void dhcp_process(DhcpProps *props, DhcpOption *opts) {
|
static void dhcp_process(DhcpProps *props, DhcpOption *opts) {
|
||||||
MSG("ENTER\n");
|
|
||||||
|
|
||||||
ETHLIB_OS_MTX_LOCK(&s.procMtx); // LOCK!
|
ETHLIB_OS_MTX_LOCK(&s.procMtx); // LOCK!
|
||||||
|
|
||||||
switch (s.state) {
|
switch (s.state) {
|
||||||
@ -323,8 +321,6 @@ static void dhcp_process(DhcpProps *props, DhcpOption *opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ETHLIB_OS_MTX_UNLOCK(&s.procMtx); // RELEASE!
|
ETHLIB_OS_MTX_UNLOCK(&s.procMtx); // RELEASE!
|
||||||
|
|
||||||
MSG("EXIT\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dhcp_resp_cb(const Pckt *pckt, PcktSieveLayerTag tag) {
|
static int dhcp_resp_cb(const Pckt *pckt, PcktSieveLayerTag tag) {
|
||||||
|
1
utils.h
1
utils.h
@ -32,6 +32,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ERROR(...) MSG(__VA_ARGS__)
|
#define ERROR(...) MSG(__VA_ARGS__)
|
||||||
|
#define WARNING(...) MSG(__VA_ARGS__)
|
||||||
#define INFO(...) MSG(__VA_ARGS__)
|
#define INFO(...) MSG(__VA_ARGS__)
|
||||||
|
|
||||||
#define SNPRINTF(s,n,...) snprintf(s,n,__VA_ARGS__)
|
#define SNPRINTF(s,n,...) snprintf(s,n,__VA_ARGS__)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user