Blame SOURCES/libsrtp-global-buffer-overflow.patch

98e5b5
Index: srtp/crypto/cipher/aes_icm.c
98e5b5
===================================================================
98e5b5
--- srtp/crypto/cipher/aes_icm.c	(revision 157386)
98e5b5
+++ srtp/crypto/cipher/aes_icm.c	(working copy)
98e5b5
@@ -165,7 +165,7 @@
98e5b5
 err_status_t
98e5b5
 aes_icm_context_init(aes_icm_ctx_t *c, const uint8_t *key, int key_len) {
98e5b5
   err_status_t status;
98e5b5
-  int base_key_len;
98e5b5
+  int base_key_len, copy_len;
98e5b5
 
98e5b5
   if (key_len > 16 && key_len < 30) /* Ismacryp */
98e5b5
     base_key_len = 16;
98e5b5
@@ -174,15 +174,20 @@
98e5b5
   else
98e5b5
     return err_status_bad_param;
98e5b5
 
98e5b5
-  /* set counter and initial values to 'offset' value */
98e5b5
-  /* Note this copies past the end of the 'key' array by 2 bytes! */
98e5b5
-  v128_copy_octet_string(&c->counter, key + base_key_len);
98e5b5
-  v128_copy_octet_string(&c->offset, key + base_key_len);
98e5b5
+  /* 
98e5b5
+   * set counter and initial values to 'offset' value, being careful not to
98e5b5
+   * go past the end of the key buffer.
98e5b5
+   */
98e5b5
+  v128_set_to_zero(&c->counter);
98e5b5
+  v128_set_to_zero(&c->offset);
98e5b5
 
98e5b5
-  /* force last two octets of the offset to zero (for srtp compatibility) */
98e5b5
-  c->offset.v8[14] = c->offset.v8[15] = 0;
98e5b5
-  c->counter.v8[14] = c->counter.v8[15] = 0;
98e5b5
+  /* force last two octets of the offset to be left zero 
98e5b5
+   * (for srtp compatibility) */
98e5b5
+  copy_len = key_len - base_key_len;
98e5b5
   
98e5b5
+  memcpy(&c->counter, key + base_key_len, copy_len);
98e5b5
+  memcpy(&c->offset, key + base_key_len, copy_len);
98e5b5
+
98e5b5
   debug_print(mod_aes_icm, 
98e5b5
 	      "key:  %s", octet_string_hex_string(key, base_key_len)); 
98e5b5
   debug_print(mod_aes_icm,