Refactor: Update the subaddress structure
authorDenis Kenzior <denkenz@gmail.com>
Wed, 10 Mar 2010 18:53:09 +0000 (12:53 -0600)
committerDenis Kenzior <denkenz@gmail.com>
Tue, 16 Mar 2010 02:02:06 +0000 (21:02 -0500)
src/stkutil.c
src/stkutil.h

index d5d963f..136efd5 100644 (file)
@@ -95,8 +95,8 @@ static gboolean parse_dataobj_alpha_id(struct comprehension_tlv_iter *iter,
 }
 
 /* Defined in TS 102.223 Section 8.3 */
-static gboolean parse_dataobj_subaddress(
-               struct comprehension_tlv_iter *iter, void *user)
+static gboolean parse_dataobj_subaddress(struct comprehension_tlv_iter *iter,
+                                               void *user)
 {
        struct stk_subaddress *subaddr = user;
        const unsigned char *data;
@@ -110,9 +110,11 @@ static gboolean parse_dataobj_subaddress(
        if (len < 1)
                return FALSE;
 
+       if (len > sizeof(subaddr->subaddr))
+               return FALSE;
+
        data = comprehension_tlv_iter_get_data(iter);
-       subaddr->subaddr_len = len;
-       subaddr->subaddr = g_malloc(len);
+       subaddr->len = len;
        memcpy(subaddr->subaddr, data, len);
 
        return TRUE;
index b67bbef..d225dd4 100644 (file)
@@ -198,10 +198,23 @@ struct stk_address {
        char *number;
 };
 
-/* Defined in TS 102.223 Section 8.3 */
+/*
+ * Defined in TS 102.223 Section 8.3
+ *
+ * The maximum size of the subaddress is different depending on the referenced
+ * specification.  According to TS 24.008 Section 10.5.4.8: "The called party
+ * subaddress is a type 4 information element with a minimum length of 2 octets
+ * and a maximum length of 23 octets"
+ *
+ * According to TS 31.102 Section 4.4.2.4: "The subaddress data contains
+ * information as defined for this purpose in TS 24.008 [9]. All information
+ * defined in TS 24.008, except the information element identifier, shall be
+ * stored in the USIM. The length of this subaddress data can be up to 22
+ * bytes."
+ */
 struct stk_subaddress {
-       unsigned int subaddr_len;
-       unsigned char *subaddr;
+       unsigned char len;
+       unsigned char *subaddr[23];
 };
 
 /* Defined in TS 102.223 Section 8.4 */