File CVE-2019-15784.patch of Package srt (Revision 04f07aa4e77f074cb4ccde5531c53336)
Currently displaying revision 04f07aa4e77f074cb4ccde5531c53336 , Show latest
xxxxxxxxxx
1
Index: srt-1.3.4/srtcore/queue.cpp
2
===================================================================
3
--- srt-1.3.4.orig/srtcore/queue.cpp
4
+++ srt-1.3.4/srtcore/queue.cpp
5
6
7
CSndUList::CSndUList():
8
m_pHeap(NULL),
9
- m_iArrayLength(4096),
10
+ m_iArrayLength(512),
11
m_iLastEntry(-1),
12
m_ListLock(),
13
m_pWindowLock(NULL),
14
15
pthread_mutex_destroy(&m_ListLock);
16
}
17
18
-void CSndUList::insert(int64_t ts, const CUDT* u)
19
-{
20
- CGuard listguard(m_ListLock);
21
-
22
- // increase the heap array size if necessary
23
- if (m_iLastEntry == m_iArrayLength - 1)
24
- {
25
- CSNode** temp = NULL;
26
-
27
- try
28
- {
29
- temp = new CSNode*[m_iArrayLength * 2];
30
- }
31
- catch(...)
32
- {
33
- return;
34
- }
35
-
36
- memcpy(temp, m_pHeap, sizeof(CSNode*) * m_iArrayLength);
37
- m_iArrayLength *= 2;
38
- delete [] m_pHeap;
39
- m_pHeap = temp;
40
- }
41
-
42
- insert_(ts, u);
43
-}
44
45
void CSndUList::update(const CUDT* u, EReschedule reschedule)
46
{
47
48
}
49
50
remove_(u);
51
+ insert_norealloc_(1, u);
52
+ return;
53
}
54
55
insert_(1, u);
56
57
58
// insert a new entry, ts is the next processing time
59
if (ts > 0)
60
- insert_(ts, u);
61
+ insert_norealloc_(ts, u);
62
63
return 1;
64
}
65
66
return m_pHeap[0]->m_llTimeStamp_tk;
67
}
68
69
+
70
+void CSndUList::realloc_()
71
+{
72
+ CSNode** temp = NULL;
73
+
74
+ try
75
+ {
76
+ temp = new CSNode *[2 * m_iArrayLength];
77
+ }
78
+ catch (...)
79
+ {
80
+ throw CUDTException(MJ_SYSTEMRES, MN_MEMORY, 0);
81
+ }
82
+
83
+ memcpy(temp, m_pHeap, sizeof(CSNode*) * m_iArrayLength);
84
+ m_iArrayLength *= 2;
85
+ delete[] m_pHeap;
86
+ m_pHeap = temp;
87
+}
88
+
89
+
90
void CSndUList::insert_(int64_t ts, const CUDT* u)
91
{
92
+ // increase the heap array size if necessary
93
+ if (m_iLastEntry == m_iArrayLength - 1)
94
+ realloc_();
95
+
96
+ insert_norealloc_(ts, u);
97
+}
98
+
99
+
100
+void CSndUList::insert_norealloc_(int64_t ts, const CUDT* u)
101
+{
102
CSNode* n = u->m_pSNode;
103
104
// do not insert repeated node
105
if (n->m_iHeapLoc >= 0)
106
return;
107
108
+ SRT_ASSERT(m_iLastEntry < m_iArrayLength);
109
+
110
m_iLastEntry ++;
111
m_pHeap[m_iLastEntry] = n;
112
n->m_llTimeStamp_tk = ts;
113
114
while (p != 0)
115
{
116
p = (q - 1) >> 1;
117
- if (m_pHeap[p]->m_llTimeStamp_tk > m_pHeap[q]->m_llTimeStamp_tk)
118
- {
119
- CSNode* t = m_pHeap[p];
120
- m_pHeap[p] = m_pHeap[q];
121
- m_pHeap[q] = t;
122
- t->m_iHeapLoc = q;
123
- q = p;
124
- }
125
- else
126
- break;
127
+ if (m_pHeap[p]->m_llTimeStamp_tk <= m_pHeap[q]->m_llTimeStamp_tk)
128
+ break;
129
+
130
+ swap(m_pHeap[p], m_pHeap[q]);
131
+ m_pHeap[q]->m_iHeapLoc = q;
132
+ q = p;
133
}
134
135
n->m_iHeapLoc = q;
136
137
138
if (m_pHeap[q]->m_llTimeStamp_tk > m_pHeap[p]->m_llTimeStamp_tk)
139
{
140
- CSNode* t = m_pHeap[p];
141
- m_pHeap[p] = m_pHeap[q];
142
- m_pHeap[p]->m_iHeapLoc = p;
143
- m_pHeap[q] = t;
144
+ swap(m_pHeap[p], m_pHeap[q]);
145
+ m_pHeap[p]->m_iHeapLoc = p;
146
m_pHeap[q]->m_iHeapLoc = q;
147
148
q = p;
149
Index: srt-1.3.4/srtcore/queue.h
150
===================================================================
151
--- srt-1.3.4.orig/srtcore/queue.h
152
+++ srt-1.3.4/srtcore/queue.h
153
154
155
static EReschedule rescheduleIf(bool cond) { return cond ? DO_RESCHEDULE : DONT_RESCHEDULE; }
156
157
- /// Insert a new UDT instance into the list.
158
- /// @param [in] ts time stamp: next processing time
159
- /// @param [in] u pointer to the UDT instance
160
-
161
- void insert(int64_t ts, const CUDT* u);
162
-
163
/// Update the timestamp of the UDT instance on the list.
164
/// @param [in] u pointer to the UDT instance
165
/// @param [in] resechedule if the timestampe shoudl be rescheduled
166
167
uint64_t getNextProcTime();
168
169
private:
170
+
171
+ /// Doubles the size of the list.
172
+ ///
173
+ void realloc_();
174
+
175
+ /// Insert a new UDT instance into the list with realloc if required.
176
+ ///
177
+ /// @param [in] ts time stamp: next processing time
178
+ /// @param [in] u pointer to the UDT instance
179
void insert_(int64_t ts, const CUDT* u);
180
+
181
+ /// Insert a new UDT instance into the list without realloc.
182
+ /// Should be called if there is a gauranteed space for the element.
183
+ ///
184
+ /// @param [in] ts time stamp: next processing time
185
+ /// @param [in] u pointer to the UDT instance
186
+
187
+ void insert_norealloc_(int64_t ts, const CUDT* u);
188
+
189
+
190
void remove_(const CUDT* u);
191
192
private:
193