smsutil: Add additional sanity check
authorDenis Kenzior <denkenz@gmail.com>
Fri, 13 Feb 2015 15:59:59 +0000 (09:59 -0600)
committerDenis Kenzior <denkenz@gmail.com>
Fri, 13 Feb 2015 15:59:59 +0000 (09:59 -0600)
We make sure that after performing the UTF8 -> GSM conversion, the
number of GSM bytes is not greater than 11, which is the maximum
payload.

src/smsutil.c

index 74afb651e8e4185674330da771b9652cc7fea1bd..9406a8a8441fcab8d9c264fc011cd6ab77f78073 100644 (file)
@@ -555,6 +555,11 @@ gboolean sms_encode_address_field(const struct sms_address *in, gboolean sc,
                if (gsm == NULL)
                        return FALSE;
 
+               if (written > 11) {
+                       g_free(gsm);
+                       return FALSE;
+               }
+
                r = pack_7bit_own_buf(gsm, written, 0, FALSE, &packed, 0, p);
 
                g_free(gsm);