Show More
@@ -172,15 +172,39 b' static int discard(struct mpatch_flist *' | |||||
172 | int postend, c, l; |
|
172 | int postend, c, l; | |
173 |
|
173 | |||
174 | while (s != src->tail) { |
|
174 | while (s != src->tail) { | |
175 | if (s->start + offset >= cut) |
|
175 | int cmpcut = s->start; | |
|
176 | if (!safeadd(offset, &cmpcut)) { | |||
|
177 | break; | |||
|
178 | } | |||
|
179 | if (cmpcut >= cut) | |||
176 | break; |
|
180 | break; | |
177 |
|
181 | |||
178 |
postend = offset |
|
182 | postend = offset; | |
|
183 | if (!safeadd(s->start, &postend)) { | |||
|
184 | break; | |||
|
185 | } | |||
|
186 | if (!safeadd(s->len, &postend)) { | |||
|
187 | break; | |||
|
188 | } | |||
179 | if (postend <= cut) { |
|
189 | if (postend <= cut) { | |
180 | offset += s->start + s->len - s->end; |
|
190 | /* do the subtraction first to avoid UB integer overflow | |
|
191 | */ | |||
|
192 | int tmp = s->start; | |||
|
193 | if (!safesub(s->end, &tmp)) { | |||
|
194 | break; | |||
|
195 | } | |||
|
196 | if (!safeadd(s->len, &tmp)) { | |||
|
197 | break; | |||
|
198 | } | |||
|
199 | if (!safeadd(tmp, &offset)) { | |||
|
200 | break; | |||
|
201 | } | |||
181 | s++; |
|
202 | s++; | |
182 | } else { |
|
203 | } else { | |
183 |
c = cut |
|
204 | c = cut; | |
|
205 | if (!safesub(offset, &c)) { | |||
|
206 | break; | |||
|
207 | } | |||
184 | if (s->end < c) |
|
208 | if (s->end < c) | |
185 | c = s->end; |
|
209 | c = s->end; | |
186 | l = cut - offset - s->start; |
|
210 | l = cut - offset - s->start; |
General Comments 0
You need to be logged in to leave comments.
Login now