projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Support receiving server capabilities
[git.git]
/
patch-delta.c
diff --git
a/patch-delta.c
b/patch-delta.c
index
a8d75ee
..
98c27be
100644
(file)
--- a/
patch-delta.c
+++ b/
patch-delta.c
@@
-20,39
+20,24
@@
void *patch_delta(void *src_buf, unsigned long src_size,
const unsigned char *data, *top;
unsigned char *dst_buf, *out, cmd;
unsigned long size;
const unsigned char *data, *top;
unsigned char *dst_buf, *out, cmd;
unsigned long size;
- int i;
- /* the smallest delta size possible is 6 bytes */
- if (delta_size < 6)
+ if (delta_size < DELTA_SIZE_MIN)
return NULL;
data = delta_buf;
top = delta_buf + delta_size;
/* make sure the orig file size matches what we expect */
return NULL;
data = delta_buf;
top = delta_buf + delta_size;
/* make sure the orig file size matches what we expect */
- size = i = 0;
- cmd = *data++;
- while (cmd) {
- if (cmd & 1)
- size |= *data++ << i;
- i += 8;
- cmd >>= 1;
- }
+ size = get_delta_hdr_size(&data);
if (size != src_size)
return NULL;
/* now the result size */
if (size != src_size)
return NULL;
/* now the result size */
- size = i = 0;
- cmd = *data++;
- while (cmd) {
- if (cmd & 1)
- size |= *data++ << i;
- i += 8;
- cmd >>= 1;
- }
- dst_buf = malloc(size);
+ size = get_delta_hdr_size(&data);
+ dst_buf = malloc(size + 1);
if (!dst_buf)
return NULL;
if (!dst_buf)
return NULL;
+ dst_buf[size] = 0;
out = dst_buf;
while (data < top) {
out = dst_buf;
while (data < top) {