Show More
@@ -238,7 +238,7 b' static struct flist *decode(const char *' | |||||
238 | struct flist *l; |
|
238 | struct flist *l; | |
239 | struct frag *lt; |
|
239 | struct frag *lt; | |
240 | const char *data = bin + 12, *end = bin + len; |
|
240 | const char *data = bin + 12, *end = bin + len; | |
241 |
|
|
241 | uint32_t decode[3]; /* for dealing with alignment issues */ | |
242 |
|
242 | |||
243 | /* assume worst case size, we won't have many of these lists */ |
|
243 | /* assume worst case size, we won't have many of these lists */ | |
244 | l = lalloc(len / 12); |
|
244 | l = lalloc(len / 12); | |
@@ -249,9 +249,9 b' static struct flist *decode(const char *' | |||||
249 |
|
249 | |||
250 | while (data <= end) { |
|
250 | while (data <= end) { | |
251 | memcpy(decode, bin, 12); |
|
251 | memcpy(decode, bin, 12); | |
252 |
lt->start = ntohl( |
|
252 | lt->start = ntohl(decode[0]); | |
253 |
lt->end = ntohl( |
|
253 | lt->end = ntohl(decode[1]); | |
254 |
lt->len = ntohl( |
|
254 | lt->len = ntohl(decode[2]); | |
255 | if (lt->start > lt->end) |
|
255 | if (lt->start > lt->end) | |
256 | break; /* sanity check */ |
|
256 | break; /* sanity check */ | |
257 | bin = data + lt->len; |
|
257 | bin = data + lt->len; | |
@@ -397,7 +397,7 b' patchedsize(PyObject *self, PyObject *ar' | |||||
397 | long orig, start, end, len, outlen = 0, last = 0; |
|
397 | long orig, start, end, len, outlen = 0, last = 0; | |
398 | int patchlen; |
|
398 | int patchlen; | |
399 | char *bin, *binend, *data; |
|
399 | char *bin, *binend, *data; | |
400 |
|
|
400 | uint32_t decode[3]; /* for dealing with alignment issues */ | |
401 |
|
401 | |||
402 | if (!PyArg_ParseTuple(args, "ls#", &orig, &bin, &patchlen)) |
|
402 | if (!PyArg_ParseTuple(args, "ls#", &orig, &bin, &patchlen)) | |
403 | return NULL; |
|
403 | return NULL; | |
@@ -407,9 +407,9 b' patchedsize(PyObject *self, PyObject *ar' | |||||
407 |
|
407 | |||
408 | while (data <= binend) { |
|
408 | while (data <= binend) { | |
409 | memcpy(decode, bin, 12); |
|
409 | memcpy(decode, bin, 12); | |
410 |
start = ntohl( |
|
410 | start = ntohl(decode[0]); | |
411 |
end = ntohl( |
|
411 | end = ntohl(decode[1]); | |
412 |
len = ntohl( |
|
412 | len = ntohl(decode[2]); | |
413 | if (start > end) |
|
413 | if (start > end) | |
414 | break; /* sanity check */ |
|
414 | break; /* sanity check */ | |
415 | bin = data + len; |
|
415 | bin = data + len; |
@@ -170,7 +170,7 b' static PyObject *parse_dirstate(PyObject' | |||||
170 | int state, mode, size, mtime; |
|
170 | int state, mode, size, mtime; | |
171 | unsigned int flen; |
|
171 | unsigned int flen; | |
172 | int len; |
|
172 | int len; | |
173 |
|
|
173 | uint32_t decode[4]; /* for alignment */ | |
174 |
|
174 | |||
175 | if (!PyArg_ParseTuple(args, "O!O!s#:parse_dirstate", |
|
175 | if (!PyArg_ParseTuple(args, "O!O!s#:parse_dirstate", | |
176 | &PyDict_Type, &dmap, |
|
176 | &PyDict_Type, &dmap, | |
@@ -194,10 +194,10 b' static PyObject *parse_dirstate(PyObject' | |||||
194 | /* unpack header */ |
|
194 | /* unpack header */ | |
195 | state = *cur; |
|
195 | state = *cur; | |
196 | memcpy(decode, cur + 1, 16); |
|
196 | memcpy(decode, cur + 1, 16); | |
197 |
mode = ntohl( |
|
197 | mode = ntohl(decode[0]); | |
198 |
size = ntohl( |
|
198 | size = ntohl(decode[1]); | |
199 |
mtime = ntohl( |
|
199 | mtime = ntohl(decode[2]); | |
200 |
flen = ntohl( |
|
200 | flen = ntohl(decode[3]); | |
201 | cur += 17; |
|
201 | cur += 17; | |
202 | if (cur + flen > end || cur + flen < cur) { |
|
202 | if (cur + flen > end || cur + flen < cur) { | |
203 | PyErr_SetString(PyExc_ValueError, "overflow in dirstate"); |
|
203 | PyErr_SetString(PyExc_ValueError, "overflow in dirstate"); | |
@@ -264,27 +264,27 b' static int _parse_index_ng(const char *d' | |||||
264 | int comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2; |
|
264 | int comp_len, uncomp_len, base_rev, link_rev, parent_1, parent_2; | |
265 | const char *c_node_id; |
|
265 | const char *c_node_id; | |
266 | const char *end = data + size; |
|
266 | const char *end = data + size; | |
267 |
|
|
267 | uint32_t decode[8]; /* to enforce alignment with inline data */ | |
268 |
|
268 | |||
269 | while (data < end) { |
|
269 | while (data < end) { | |
270 | unsigned int step; |
|
270 | unsigned int step; | |
271 |
|
271 | |||
272 |
memcpy(decode, data, |
|
272 | memcpy(decode, data, 32); | |
273 |
offset_flags = ntohl( |
|
273 | offset_flags = ntohl(decode[1]); | |
274 | if (n == 0) /* mask out version number for the first entry */ |
|
274 | if (n == 0) /* mask out version number for the first entry */ | |
275 | offset_flags &= 0xFFFF; |
|
275 | offset_flags &= 0xFFFF; | |
276 | else { |
|
276 | else { | |
277 |
uint32_t offset_high = ntohl( |
|
277 | uint32_t offset_high = ntohl(decode[0]); | |
278 | offset_flags |= ((uint64_t)offset_high) << 32; |
|
278 | offset_flags |= ((uint64_t)offset_high) << 32; | |
279 | } |
|
279 | } | |
280 |
|
280 | |||
281 |
comp_len = ntohl( |
|
281 | comp_len = ntohl(decode[2]); | |
282 |
uncomp_len = ntohl( |
|
282 | uncomp_len = ntohl(decode[3]); | |
283 |
base_rev = ntohl( |
|
283 | base_rev = ntohl(decode[4]); | |
284 |
link_rev = ntohl( |
|
284 | link_rev = ntohl(decode[5]); | |
285 |
parent_1 = ntohl( |
|
285 | parent_1 = ntohl(decode[6]); | |
286 |
parent_2 = ntohl( |
|
286 | parent_2 = ntohl(decode[7]); | |
287 |
c_node_id = d |
|
287 | c_node_id = data + 32; | |
288 |
|
288 | |||
289 | entry = Py_BuildValue("Liiiiiis#", offset_flags, comp_len, |
|
289 | entry = Py_BuildValue("Liiiiiis#", offset_flags, comp_len, | |
290 | uncomp_len, base_rev, link_rev, |
|
290 | uncomp_len, base_rev, link_rev, |
General Comments 0
You need to be logged in to leave comments.
Login now