summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte2011-08-16 13:51:07 +0200
committerPablo Neira Ayuso2011-08-16 13:51:07 +0200
commit1ef2457fba62d717ff2aadf8e7171e3bdb88948e (patch)
treefd3f54d608a931438b85929d21f3d4ef0d94171a
parentDAHDI: Fix case where we have multiple E1 ports/cards (spans) (diff)
downloadlibosmo-abis-1ef2457fba62d717ff2aadf8e7171e3bdb88948e.tar.gz
libosmo-abis-1ef2457fba62d717ff2aadf8e7171e3bdb88948e.tar.xz
libosmo-abis-1ef2457fba62d717ff2aadf8e7171e3bdb88948e.zip
LAPD: Remove all calls to 'assert' from the code
For a system-level daemon, no protocol parser error should ever call assert, which would take down the entire process.
-rw-r--r--src/input/lapd.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/input/lapd.c b/src/input/lapd.c
index 0d4cfc4..1b4984f 100644
--- a/src/input/lapd.c
+++ b/src/input/lapd.c
@@ -33,7 +33,6 @@
#include <stdio.h>
#include <string.h>
-#include <assert.h>
#include <errno.h>
#include <osmocom/abis/lapd.h>
@@ -355,14 +354,20 @@ uint8_t *lapd_receive(struct lapd_instance *li, uint8_t * data, unsigned int len
nr = -1;
if ((data[2] & 1) == 0) {
typ = LAPD_TYPE_I;
- assert(len >= 4);
+ if (len < 4) {
+ LOGP(DMI, LOGL_ERROR, "LAPD I frame, len %d < 4\n", len);
+ return NULL;
+ }
ns = data[2] >> 1;
nr = data[3] >> 1;
pf = data[3] & 1;
cmd = LAPD_CMD_I;
} else if ((data[2] & 3) == 1) {
typ = LAPD_TYPE_S;
- assert(len >= 4);
+ if (len < 4) {
+ LOGP(DMI, LOGL_ERROR, "LAPD S frame, len %d < 4\n", len);
+ return NULL;
+ }
nr = data[3] >> 1;
pf = data[3] & 1;
switch (data[2]) {
@@ -447,7 +452,9 @@ uint8_t *lapd_receive(struct lapd_instance *li, uint8_t * data, unsigned int len
DEBUGP(DLMI, "DOUBLE FRAME, ignoring\n");
cmd = 0; // ignore
} else {
- assert(0);
+ LOGP(DMI, LOGL_ERROR, "LAPD: Out of order "
+ "ns %d != vr %d, ignoring\n", ns, sap->vr);
+ return NULL;
};
} else {
//printf("IN SEQUENCE\n");