Hello Max, Harald Welte, Jenkins Builder, Holger Freyther,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/2446

to look at the new patch set (#3).

gsm0808: fix length check of the element decoder functions

The length check of the decoder functions is not entirely
correct. The check also checks for values below zero,
which does not make sense, since the length is encoded
as uint8_t.

For some elements a minimum length is known (in most cases
this is 1), so checking for zero is sufficient but in some
cases (e.g. channel type) the spec mentions a minimum and
maximum length. This is now also reflected in the code.

Tweaked-by: nhofmeyr
Change-Id: I78bc887f68d1963d28c6fcd631ac20ccd893d6d6
---
M src/gsm/gsm0808_utils.c
1 file changed, 6 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/46/2446/3

diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index 00da04b..c636adf 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -104,7 +104,7 @@
        OSMO_ASSERT(ss);
        if (!elem)
                return -EINVAL;
-       if (len <= 0)
+       if (len == 0)
                return -EINVAL;
 
        memset(ss, 0, sizeof(*ss));
@@ -261,7 +261,7 @@
        OSMO_ASSERT(sc);
        if (!elem)
                return -EINVAL;
-       if (len <= 0)
+       if (len == 0)
                return -EINVAL;
 
        memset(sc, 0, sizeof(*sc));
@@ -377,7 +377,7 @@
        OSMO_ASSERT(scl);
        if (!elem)
                return -EINVAL;
-       if (len <= 0)
+       if (len == 0)
                return -EINVAL;
 
        memset(scl, 0, sizeof(*scl));
@@ -461,7 +461,7 @@
        OSMO_ASSERT(ct);
        if (!elem)
                return -EINVAL;
-       if (len <= 0)
+       if (len < 3 || len > 11)
                return -EINVAL;
 
        memset(ct, 0, sizeof(*ct));
@@ -537,7 +537,7 @@
        OSMO_ASSERT(ei);
        if (!elem)
                return -EINVAL;
-       if (len <= 0)
+       if (len == 0)
                return -EINVAL;
 
        memset(ei, 0, sizeof(*ei));
@@ -614,7 +614,7 @@
        OSMO_ASSERT(cil);
        if (!elem)
                return -EINVAL;
-       if (len <= 0)
+       if (len == 0)
                return -EINVAL;
 
        memset(cil, 0, sizeof(*cil));

-- 
To view, visit https://gerrit.osmocom.org/2446
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I78bc887f68d1963d28c6fcd631ac20ccd893d6d6
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Holger Freyther <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <[email protected]>

Reply via email to