1==== //depot/google3/third_party/libsrtp/README.google#8 - None ====
2# action=edit type=text
3--- google3/third_party/libsrtp/README.google	2011-02-22 19:05:30.000000000 -0800
4+++ google3/third_party/libsrtp/README.google	2011-05-27 17:56:49.000000000 -0700
5@@ -21,4 +21,6 @@
6 - all patches are stored individually in the googlepatches subdirectory
7 - iOS related changes.
8   undefine HAVE_BYTESWAP_H in config.h
9-  Fix debug build compile errors: added static keyword to inline methods and undefined DEBUG before #define DEBUG
10\ No newline at end of file
11+  Fix debug build compile errors: added static keyword to inline methods and undefined DEBUG before #define DEBUG
12+- Fixed a bug related to replay detection when sequence number rolls back
13+  arround 0. (Currently contacting libsrtp developers for upstream.)
14==== //depot/google3/third_party/libsrtp/crypto/replay/rdbx.c#5 - None ====
15# action=edit type=text
16--- google3/third_party/libsrtp/crypto/replay/rdbx.c	2010-02-25 06:36:30.000000000 -0800
17+++ google3/third_party/libsrtp/crypto/replay/rdbx.c	2011-05-27 17:56:49.000000000 -0700
18@@ -145,7 +145,16 @@
19   if (local_seq < seq_num_median) {
20     if (s - local_seq > seq_num_median) {
21       guess_roc = local_roc - 1;
22-      difference = seq_num_max - s + local_seq;
23+      // The return value is the relative difference from local_seq to s.
24+      // The original value is negation of its purpose.  According to document
25+      // http://www.ietf.org/rfc/rfc3711.txt, when this condition is true, the
26+      // resulting new index should be (local_roc-1, s).  But original logic
27+      // will end up positive difference and rdbx_check would pass.  Hence after
28+      // rdbx_add_index would make local index to be the wrong value because
29+      // local index should not be updated in this case.  For example, when
30+      // local index is (1, 100) and next sequence is 65530, the wrong updated
31+      // index would be (1, 205).
32+      difference = s - local_seq - seq_num_max;
33     } else {
34       guess_roc = local_roc;
35       difference = s - local_seq;
36==== //depot/google3/third_party/libsrtp/test/rdbx_driver.c#5 - None ====
37# action=edit type=text
38--- google3/third_party/libsrtp/test/rdbx_driver.c	2010-02-25 06:36:30.000000000 -0800
39+++ google3/third_party/libsrtp/test/rdbx_driver.c	2011-05-27 17:56:49.000000000 -0700
40@@ -226,7 +226,7 @@
41    *  test sequential insertion
42    */
43   printf("\ttesting sequential insertion...");
44-  for (idx=0; idx < num_trials; idx++) {
45+  for (idx=0; idx < (uint32_t)num_trials; idx++) {
46     status = rdbx_check_add(&rdbx, idx);
47     if (status)
48       return status;
49@@ -245,7 +245,7 @@
50     printf("warning: no false positive tests performed\n");
51   }
52   printf("\ttesting for false positives...");
53-  for (idx=0; idx < num_fp_trials; idx++) {
54+  for (idx=0; idx < (uint32_t)num_fp_trials; idx++) {
55     status = rdbx_check_expect_failure(&rdbx, idx);
56     if (status)
57       return status;
58@@ -269,12 +269,34 @@
59   ut_init(&utc);
60
61   printf("\ttesting non-sequential insertion...");
62-  for (idx=0; idx < num_trials; idx++) {
63+  for (idx=0; idx < (uint32_t)num_trials; idx++) {
64     ircvd = ut_next_index(&utc);
65     status = rdbx_check_unordered(&rdbx, ircvd);
66     if (status)
67       return status;
68   }
69+  printf("passed\n");
70+
71+  /*
72+   * test a replay condition close to zero.
73+   */
74+  rdbx_uninit(&rdbx);
75+
76+  if (rdbx_init(&rdbx, ws) != err_status_ok) {
77+    printf("replay_init failed\n");
78+    return err_status_init_fail;
79+  }
80+
81+  printf("\ttesting replay close to zero...");
82+  status = rdbx_check_add(&rdbx, 1);
83+  if (status)
84+    return status;
85+  status = rdbx_check_expect_failure(&rdbx, 64500);
86+  if (status)
87+    return status;
88+  status = rdbx_check_add(&rdbx, 2);
89+  if (status)
90+    return status;
91   printf("passed\n");
92
93   rdbx_uninit(&rdbx);
94@@ -303,7 +325,7 @@
95
96   failures = 0;
97   timer = clock();
98-  for(i=0; i < num_trials; i++) {
99+  for(i=0; i < (uint32_t)num_trials; i++) {
100
101     delta = index_guess(&rdbx.index, &est, i);
102
103@@ -321,4 +343,3 @@
104
105   return (double) CLOCKS_PER_SEC * num_trials / timer;
106 }
107-
108