Skip to contentSkip to conversation

unit: Fix out of bounds

PATCH Applied Luiz Augusto von Dentz 1 participant 2 messages Aug 27, 2018 – Aug 31, 2018 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 unit: Fix out of bounds

From: Luiz Augusto von Dentz <[email protected]>

Test /gobex/test_stream_put_req requires 5 buffers to complete.

---
 unit/util.c | 5 +++++
 unit/util.h | 6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
unit/util.c +5 -0
index 8e3115fe3..ce4d65add 100644
@@ -188,6 +188,11 @@ send:
 		goto failed;
 	}
 
+	if (d->count >= TEST_BUF_MAX) {
+		g_print("io_cb count %u\n", d->count);
+		goto failed;
+	}
+
 	if (d->recv[d->count].len < 0 || (gssize) expect_len < 0)
 		return test_io_cb(io, G_IO_OUT, user_data);
 
unit/util.h +4 -2
index 6783c524e..b13fd2f16 100644
@@ -19,6 +19,8 @@
  *
  */
 
+#define TEST_BUF_MAX 5
+
 enum {
 	TEST_ERROR_TIMEOUT,
 	TEST_ERROR_UNEXPECTED,
@@ -32,8 +34,8 @@ struct test_buf {
 struct test_data {
 	guint count;
 	GError *err;
-	struct test_buf recv[4];
-	struct test_buf send[4];
+	struct test_buf recv[TEST_BUF_MAX];
+	struct test_buf send[TEST_BUF_MAX];
 	guint provide_delay;
 	GObex *obex;
 	guint id;
Signature · 1 line
2.17.1
author maintainer Applied
#1 lore raw

Hi,

Quoted 49 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

Test /gobex/test_stream_put_req requires 5 buffers to complete.

---
 unit/util.c | 5 +++++
 unit/util.h | 6 ++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
unit/util.c +5 -0
index 8e3115fe3..ce4d65add 100644
@@ -188,6 +188,11 @@ send:
                goto failed;
        }
 
+       if (d->count >= TEST_BUF_MAX) {
+               g_print("io_cb count %u\n", d->count);
+               goto failed;
+       }
+
        if (d->recv[d->count].len < 0 || (gssize) expect_len < 0)
                return test_io_cb(io, G_IO_OUT, user_data);
 
unit/util.h +4 -3
index 6783c524e..b13fd2f16 100644
@@ -19,6 +19,8 @@
  *
  */
 
+#define TEST_BUF_MAX 5
+
 enum {
        TEST_ERROR_TIMEOUT,
        TEST_ERROR_UNEXPECTED,
@@ -32,8 +34,8 @@ struct test_buf {
 struct test_data {
        guint count;
        GError *err;
-       struct test_buf recv[4];
-       struct test_buf send[4];
+       struct test_buf recv[TEST_BUF_MAX];
+       struct test_buf send[TEST_BUF_MAX];
        guint provide_delay;
        GObex *obex;
        guint id;
--
Quoted 1 line

2.17.1

Applied.

Signature · 1 line
Luiz Augusto von Dentz