summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2018-12-27 17:25:48 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2018-12-29 10:43:31 +0100
commit93c588892a86333fc3cfa66b7c5da2e7ff4e7e6c (patch)
tree081ca57d5d9e47bf1c3e8cfa5b2719388558d5bf /src/lib/dev.c
parent9dab3985812e75071271ce69000561156d0d9374 (diff)
downloadouroboros-93c588892a86333fc3cfa66b7c5da2e7ff4e7e6c.tar.gz
ouroboros-93c588892a86333fc3cfa66b7c5da2e7ff4e7e6c.zip
lib: Fix deallocating non-initialized np1 flows
This fixes the deallocation of non-initialized IPCP flows. These can occur when some operations are not implemented. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 57dfc3f2..50b12b43 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -667,7 +667,10 @@ int flow_dealloc(int fd)
pthread_rwlock_rdlock(&ai.lock);
- assert(ai.flows[fd].flow_id >= 0);
+ if (ai.flows[fd].flow_id < 0) {
+ pthread_rwlock_unlock(&ai.lock);
+ return -ENOTALLOC;
+ }
msg.flow_id = ai.flows[fd].flow_id;
@@ -1467,7 +1470,7 @@ void ipcp_sdb_release(struct shm_du_buff * sdb)
shm_rdrbuff_remove(ai.rdrb, shm_du_buff_get_idx(sdb));
}
-void ipcp_flow_fini(int fd)
+int ipcp_flow_fini(int fd)
{
struct shm_rbuff * rx_rb;
@@ -1475,6 +1478,11 @@ void ipcp_flow_fini(int fd)
pthread_rwlock_rdlock(&ai.lock);
+ if (ai.flows[fd].flow_id < 0) {
+ pthread_rwlock_unlock(&ai.lock);
+ return -1;
+ }
+
shm_rbuff_set_acl(ai.flows[fd].rx_rb, ACL_FLOWDOWN);
shm_rbuff_set_acl(ai.flows[fd].tx_rb, ACL_FLOWDOWN);
@@ -1489,6 +1497,7 @@ void ipcp_flow_fini(int fd)
if (rx_rb != NULL)
shm_rbuff_fini(rx_rb);
+ return 0;
}
int ipcp_flow_get_qoscube(int fd,