Ensure that the input to strtoul ends with a null.
authorEvan Huus <eapache@gmail.com>
Sat, 8 Mar 2014 15:43:39 +0000 (10:43 -0500)
committerMartin Kaiser <wireshark@kaiser.cx>
Sat, 8 Mar 2014 18:30:16 +0000 (18:30 +0000)
Otherwise it runs past the end of the array into stack memory. Should fix the
intermittent DVB-CI decryption test suite failures.

Change-Id: Ice17497e661c8579baf3a546efcb5529beda6b49
Reviewed-on: https://code.wireshark.org/review/559
Tested-by: Martin Kaiser <wireshark@kaiser.cx>
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
epan/dissectors/packet-dvbci.c

index 032d6049b6cc8dbcada5458a1da06bd53549b203..6c38870f8c5aace21cd4fc5d85fc8f32b8aff40c 100644 (file)
@@ -2180,7 +2180,7 @@ pref_key_string_to_bin(const gchar *key_string, unsigned char **key_bin)
 {
     int  key_string_len;
     int  i, j;
-    char input[2];
+    char input[3];
 
     if (!key_string || !key_bin)
         return -1;
@@ -2188,6 +2188,7 @@ pref_key_string_to_bin(const gchar *key_string, unsigned char **key_bin)
     if (key_string_len != 2*AES_KEY_LEN)
         return -1;
     *key_bin = (unsigned char*)g_malloc(key_string_len/2);
+    input[2] = '\0';
 
     j=0;
     for (i=0; i<key_string_len-1; i+=2) {