Hello Jenkins Builder,

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

    https://gerrit.osmocom.org/4645

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

mobile/gsm322.c: replace memset() by simple for-loop

This change prevents a possible buffer overrun in case of
incorrect min / max values are passed and the compiler
warning about possibility of calling memset() with
constant zero length parameter.

Change-Id: I2d8d78474614939659a7f24d5007b1c890776b1a
---
M src/host/layer23/src/mobile/gsm322.c
1 file changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/45/4645/2

diff --git a/src/host/layer23/src/mobile/gsm322.c 
b/src/host/layer23/src/mobile/gsm322.c
index ad6a83b..9fda91e 100644
--- a/src/host/layer23/src/mobile/gsm322.c
+++ b/src/host/layer23/src/mobile/gsm322.c
@@ -313,6 +313,7 @@
 static char *bargraph(int value, int min, int max)
 {
        static char bar[128];
+       int i;
 
        /* shift value to the range of min..max */
        if (value < min)
@@ -322,8 +323,9 @@
        else
                value -= min;
 
-       memset(bar, '=', value);
-       bar[value] = '\0';
+       for (i = 0; i < value && i < sizeof(bar) - 1; i++)
+               bar[i] = '=';
+       bar[i] = '\0';
 
        return bar;
 }

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I2d8d78474614939659a7f24d5007b1c890776b1a
Gerrit-PatchSet: 2
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <[email protected]>
Gerrit-Reviewer: Vadim Yanitskiy <[email protected]>

Reply via email to