Hi Alexander,

On 01/16/2018 09:33 AM, Alexander Couzens wrote:
---
  drivers/qmimodem/ussd.c | 187 ++++++++++++++++++++++++++++++++++++++++++++++--
  1 file changed, 183 insertions(+), 4 deletions(-)

diff --git a/drivers/qmimodem/ussd.c b/drivers/qmimodem/ussd.c
index 90c32097c94d..c1cb7d3697d1 100644
--- a/drivers/qmimodem/ussd.c
+++ b/drivers/qmimodem/ussd.c
@@ -3,6 +3,7 @@
   *  oFono - Open Source Telephony
   *
   *  Copyright (C) 2011-2012  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2017 by sysmocom s.f.m.c. GmbH <[email protected]>
   *
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License version 2 as
@@ -23,20 +24,103 @@
  #include <config.h>
  #endif
+#define _GNU_SOURCE
+#include <string.h>
+
+#include <glib.h>
+
  #include <ofono/log.h>
  #include <ofono/modem.h>
  #include <ofono/ussd.h>
-
+#include <smsutil.h>
  #include "qmi.h"
#include "qmimodem.h" +#include "voice.h"
+
  struct ussd_data {
        struct qmi_service *voice;
        uint16_t major;
        uint16_t minor;
  };
+static int validate_ussd_data(const struct qmi_ussd_data *data, int size)

drivers/qmimodem/ussd.c: In function ‘validate_ussd_data’:
drivers/qmimodem/ussd.c:53:11: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
  if (size < sizeof(*data))
           ^
drivers/qmimodem/ussd.c:56:11: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
  if (size < sizeof(*data) + data->length)

I went ahead and changed the type of 'size' to a uint16_t.

+{
+       if (data == NULL)
+               return 1;
+
+       if (size < sizeof(*data))
+               return 1;
+
+       if (size < sizeof(*data) + data->length)
+               return 1;
+
+       if (data->dcs < QMI_USSD_DCS_ASCII || data->dcs > QMI_USSD_DCS_UCS2)
+               return 1;
+
+       return 0;
+}
+

I also silently fixed up (git commit --amend) a couple of whitespace issues and applied this patch.

Regards,
-Denis
_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to