rugged 0.27.7 → 0.27.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +6 -2
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.c.in +29 -0
- data/vendor/libgit2/cmake/Modules/CheckPrototypeDefinition.cmake +96 -0
- data/vendor/libgit2/cmake/Modules/FindIconv.cmake +11 -6
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +0 -2
- data/vendor/libgit2/include/git2.h +0 -1
- data/vendor/libgit2/include/git2/attr.h +7 -18
- data/vendor/libgit2/include/git2/blame.h +22 -39
- data/vendor/libgit2/include/git2/blob.h +1 -1
- data/vendor/libgit2/include/git2/branch.h +1 -1
- data/vendor/libgit2/include/git2/buffer.h +2 -14
- data/vendor/libgit2/include/git2/checkout.h +12 -13
- data/vendor/libgit2/include/git2/cherrypick.h +4 -6
- data/vendor/libgit2/include/git2/clone.h +6 -8
- data/vendor/libgit2/include/git2/commit.h +0 -28
- data/vendor/libgit2/include/git2/common.h +0 -27
- data/vendor/libgit2/include/git2/config.h +0 -1
- data/vendor/libgit2/include/git2/describe.h +7 -30
- data/vendor/libgit2/include/git2/diff.h +22 -32
- data/vendor/libgit2/include/git2/errors.h +0 -1
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/merge.h +8 -10
- data/vendor/libgit2/include/git2/proxy.h +5 -9
- data/vendor/libgit2/include/git2/rebase.h +4 -7
- data/vendor/libgit2/include/git2/refs.h +1 -1
- data/vendor/libgit2/include/git2/refspec.h +0 -17
- data/vendor/libgit2/include/git2/remote.h +10 -12
- data/vendor/libgit2/include/git2/repository.h +5 -7
- data/vendor/libgit2/include/git2/revert.h +3 -5
- data/vendor/libgit2/include/git2/stash.h +8 -11
- data/vendor/libgit2/include/git2/status.h +3 -7
- data/vendor/libgit2/include/git2/submodule.h +7 -8
- data/vendor/libgit2/include/git2/sys/index.h +0 -3
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +1 -6
- data/vendor/libgit2/include/git2/transaction.h +0 -1
- data/vendor/libgit2/include/git2/types.h +5 -8
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/include/git2/worktree.h +11 -46
- data/vendor/libgit2/src/CMakeLists.txt +28 -91
- data/vendor/libgit2/src/annotated_commit.c +4 -4
- data/vendor/libgit2/src/apply.c +6 -5
- data/vendor/libgit2/src/attr.c +4 -4
- data/vendor/libgit2/src/attr_file.c +5 -5
- data/vendor/libgit2/src/attrcache.c +2 -2
- data/vendor/libgit2/src/blame.c +4 -11
- data/vendor/libgit2/src/blame.h +0 -1
- data/vendor/libgit2/src/blame_git.c +5 -8
- data/vendor/libgit2/src/blob.c +5 -5
- data/vendor/libgit2/src/branch.c +20 -20
- data/vendor/libgit2/src/buffer.c +4 -9
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/checkout.c +24 -33
- data/vendor/libgit2/src/cherrypick.c +3 -3
- data/vendor/libgit2/src/clone.c +13 -13
- data/vendor/libgit2/src/commit.c +5 -18
- data/vendor/libgit2/src/commit_list.c +9 -3
- data/vendor/libgit2/src/common.h +1 -3
- data/vendor/libgit2/src/config.c +15 -6
- data/vendor/libgit2/src/config_file.c +249 -193
- data/vendor/libgit2/src/config_parse.c +66 -89
- data/vendor/libgit2/src/config_parse.h +2 -2
- data/vendor/libgit2/src/crlf.c +3 -9
- data/vendor/libgit2/src/diff.c +2 -2
- data/vendor/libgit2/src/diff_driver.c +3 -3
- data/vendor/libgit2/src/diff_file.c +3 -3
- data/vendor/libgit2/src/diff_generate.c +3 -4
- data/vendor/libgit2/src/diff_print.c +8 -8
- data/vendor/libgit2/src/diff_tform.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.c +0 -12
- data/vendor/libgit2/src/features.h.in +0 -2
- data/vendor/libgit2/src/fetch.c +2 -2
- data/vendor/libgit2/src/fetchhead.c +5 -5
- data/vendor/libgit2/src/filebuf.c +4 -4
- data/vendor/libgit2/src/fileops.c +10 -10
- data/vendor/libgit2/src/filter.c +9 -3
- data/vendor/libgit2/src/global.c +12 -17
- data/vendor/libgit2/src/hash.h +0 -2
- data/vendor/libgit2/src/ignore.c +5 -5
- data/vendor/libgit2/src/index.c +40 -80
- data/vendor/libgit2/src/index.h +0 -10
- data/vendor/libgit2/src/indexer.c +9 -9
- data/vendor/libgit2/src/iterator.c +8 -8
- data/vendor/libgit2/src/khash.h +1 -3
- data/vendor/libgit2/src/merge.c +7 -7
- data/vendor/libgit2/src/netops.c +5 -5
- data/vendor/libgit2/src/notes.c +2 -2
- data/vendor/libgit2/src/odb.c +9 -9
- data/vendor/libgit2/src/odb_loose.c +22 -18
- data/vendor/libgit2/src/odb_pack.c +3 -3
- data/vendor/libgit2/src/pack-objects.c +3 -3
- data/vendor/libgit2/src/pack.c +5 -5
- data/vendor/libgit2/src/pack.h +1 -1
- data/vendor/libgit2/src/parse.c +7 -4
- data/vendor/libgit2/src/patch.c +1 -1
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +4 -24
- data/vendor/libgit2/src/path.c +140 -39
- data/vendor/libgit2/src/path.h +84 -2
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/push.c +2 -2
- data/vendor/libgit2/src/rebase.c +23 -20
- data/vendor/libgit2/src/refdb_fs.c +34 -65
- data/vendor/libgit2/src/refs.c +16 -13
- data/vendor/libgit2/src/refspec.c +5 -30
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +43 -43
- data/vendor/libgit2/src/repository.c +56 -56
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/revert.c +3 -3
- data/vendor/libgit2/src/revparse.c +7 -6
- data/vendor/libgit2/src/revwalk.c +20 -48
- data/vendor/libgit2/src/revwalk.h +1 -2
- data/vendor/libgit2/src/settings.c +1 -25
- data/vendor/libgit2/src/signature.c +4 -2
- data/vendor/libgit2/src/stash.c +34 -80
- data/vendor/libgit2/src/status.c +1 -1
- data/vendor/libgit2/src/streams/curl.c +1 -1
- data/vendor/libgit2/src/streams/openssl.c +34 -132
- data/vendor/libgit2/src/streams/openssl.h +107 -0
- data/vendor/libgit2/src/streams/tls.c +0 -3
- data/vendor/libgit2/src/submodule.c +83 -118
- data/vendor/libgit2/src/sysdir.c +4 -4
- data/vendor/libgit2/src/tag.c +12 -12
- data/vendor/libgit2/src/trace.h +1 -1
- data/vendor/libgit2/src/trailer.c +6 -6
- data/vendor/libgit2/src/transport.c +2 -2
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +2 -2
- data/vendor/libgit2/src/transports/git.c +1 -1
- data/vendor/libgit2/src/transports/http.c +15 -12
- data/vendor/libgit2/src/transports/local.c +7 -7
- data/vendor/libgit2/src/transports/smart.c +15 -20
- data/vendor/libgit2/src/transports/smart.h +5 -5
- data/vendor/libgit2/src/transports/smart_pkt.c +131 -123
- data/vendor/libgit2/src/transports/smart_protocol.c +38 -48
- data/vendor/libgit2/src/transports/ssh.c +1 -1
- data/vendor/libgit2/src/transports/winhttp.c +26 -21
- data/vendor/libgit2/src/tree-cache.c +2 -2
- data/vendor/libgit2/src/tree.c +69 -23
- data/vendor/libgit2/src/tree.h +12 -0
- data/vendor/libgit2/src/util.c +99 -52
- data/vendor/libgit2/src/util.h +138 -14
- data/vendor/libgit2/src/vector.c +13 -8
- data/vendor/libgit2/src/win32/findfile.c +2 -2
- data/vendor/libgit2/src/win32/posix_w32.c +1 -1
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.c +0 -94
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +75 -28
- data/vendor/libgit2/src/worktree.c +44 -65
- data/vendor/libgit2/src/worktree.h +0 -2
- data/vendor/libgit2/src/xdiff/xdiffi.c +1 -3
- metadata +5 -17
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +0 -93
- data/vendor/libgit2/include/git2/mailmap.h +0 -115
- data/vendor/libgit2/include/git2/sys/alloc.h +0 -101
- data/vendor/libgit2/include/git2/sys/path.h +0 -55
- data/vendor/libgit2/src/alloc.c +0 -47
- data/vendor/libgit2/src/alloc.h +0 -40
- data/vendor/libgit2/src/hash/hash_mbedtls.c +0 -38
- data/vendor/libgit2/src/hash/hash_mbedtls.h +0 -20
- data/vendor/libgit2/src/mailmap.c +0 -485
- data/vendor/libgit2/src/mailmap.h +0 -35
- data/vendor/libgit2/src/stdalloc.c +0 -120
- data/vendor/libgit2/src/stdalloc.h +0 -17
- data/vendor/libgit2/src/streams/mbedtls.c +0 -463
- data/vendor/libgit2/src/streams/mbedtls.h +0 -20
@@ -40,7 +40,7 @@ typedef enum {
|
|
40
40
|
GIT_PKT_HAVE,
|
41
41
|
GIT_PKT_ACK,
|
42
42
|
GIT_PKT_NAK,
|
43
|
-
|
43
|
+
GIT_PKT_PACK__UNUSED,
|
44
44
|
GIT_PKT_COMMENT,
|
45
45
|
GIT_PKT_ERR,
|
46
46
|
GIT_PKT_DATA,
|
@@ -50,7 +50,7 @@ typedef enum {
|
|
50
50
|
GIT_PKT_UNPACK,
|
51
51
|
} git_pkt_type;
|
52
52
|
|
53
|
-
/* Used for multi_ack and
|
53
|
+
/* Used for multi_ack and mutli_ack_detailed */
|
54
54
|
enum git_ack_status {
|
55
55
|
GIT_ACK_NONE,
|
56
56
|
GIT_ACK_CONTINUE,
|
@@ -91,7 +91,7 @@ typedef struct {
|
|
91
91
|
|
92
92
|
typedef struct {
|
93
93
|
git_pkt_type type;
|
94
|
-
|
94
|
+
size_t len;
|
95
95
|
char data[GIT_FLEX_ARRAY];
|
96
96
|
} git_pkt_data;
|
97
97
|
|
@@ -99,7 +99,7 @@ typedef git_pkt_data git_pkt_progress;
|
|
99
99
|
|
100
100
|
typedef struct {
|
101
101
|
git_pkt_type type;
|
102
|
-
|
102
|
+
size_t len;
|
103
103
|
char error[GIT_FLEX_ARRAY];
|
104
104
|
} git_pkt_err;
|
105
105
|
|
@@ -189,7 +189,7 @@ int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream
|
|
189
189
|
int git_smart__update_heads(transport_smart *t, git_vector *symrefs);
|
190
190
|
|
191
191
|
/* smart_pkt.c */
|
192
|
-
int git_pkt_parse_line(git_pkt **head, const char
|
192
|
+
int git_pkt_parse_line(git_pkt **head, const char **endptr, const char *line, size_t linelen);
|
193
193
|
int git_pkt_buffer_flush(git_buf *buf);
|
194
194
|
int git_pkt_send_flush(GIT_SOCKET s);
|
195
195
|
int git_pkt_buffer_done(git_buf *buf);
|
@@ -43,34 +43,43 @@ static int flush_pkt(git_pkt **out)
|
|
43
43
|
static int ack_pkt(git_pkt **out, const char *line, size_t len)
|
44
44
|
{
|
45
45
|
git_pkt_ack *pkt;
|
46
|
-
GIT_UNUSED(line);
|
47
|
-
GIT_UNUSED(len);
|
48
46
|
|
49
47
|
pkt = git__calloc(1, sizeof(git_pkt_ack));
|
50
48
|
GITERR_CHECK_ALLOC(pkt);
|
51
|
-
|
52
49
|
pkt->type = GIT_PKT_ACK;
|
53
|
-
line += 3;
|
54
|
-
len -= 3;
|
55
50
|
|
56
|
-
if (len
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
51
|
+
if (git__prefixncmp(line, len, "ACK "))
|
52
|
+
goto out_err;
|
53
|
+
line += 4;
|
54
|
+
len -= 4;
|
55
|
+
|
56
|
+
if (len < GIT_OID_HEXSZ || git_oid_fromstr(&pkt->oid, line) < 0)
|
57
|
+
goto out_err;
|
58
|
+
line += GIT_OID_HEXSZ;
|
59
|
+
len -= GIT_OID_HEXSZ;
|
61
60
|
|
62
|
-
if (len
|
63
|
-
|
61
|
+
if (len && line[0] == ' ') {
|
62
|
+
line++;
|
63
|
+
len--;
|
64
|
+
|
65
|
+
if (!git__prefixncmp(line, len, "continue"))
|
64
66
|
pkt->status = GIT_ACK_CONTINUE;
|
65
|
-
if (!
|
67
|
+
else if (!git__prefixncmp(line, len, "common"))
|
66
68
|
pkt->status = GIT_ACK_COMMON;
|
67
|
-
if (!
|
69
|
+
else if (!git__prefixncmp(line, len, "ready"))
|
68
70
|
pkt->status = GIT_ACK_READY;
|
71
|
+
else
|
72
|
+
goto out_err;
|
69
73
|
}
|
70
74
|
|
71
75
|
*out = (git_pkt *) pkt;
|
72
76
|
|
73
77
|
return 0;
|
78
|
+
|
79
|
+
out_err:
|
80
|
+
giterr_set(GITERR_NET, "error parsing ACK pkt-line");
|
81
|
+
git__free(pkt);
|
82
|
+
return -1;
|
74
83
|
}
|
75
84
|
|
76
85
|
static int nak_pkt(git_pkt **out)
|
@@ -86,19 +95,6 @@ static int nak_pkt(git_pkt **out)
|
|
86
95
|
return 0;
|
87
96
|
}
|
88
97
|
|
89
|
-
static int pack_pkt(git_pkt **out)
|
90
|
-
{
|
91
|
-
git_pkt *pkt;
|
92
|
-
|
93
|
-
pkt = git__malloc(sizeof(git_pkt));
|
94
|
-
GITERR_CHECK_ALLOC(pkt);
|
95
|
-
|
96
|
-
pkt->type = GIT_PKT_PACK;
|
97
|
-
*out = pkt;
|
98
|
-
|
99
|
-
return 0;
|
100
|
-
}
|
101
|
-
|
102
98
|
static int comment_pkt(git_pkt **out, const char *line, size_t len)
|
103
99
|
{
|
104
100
|
git_pkt_comment *pkt;
|
@@ -120,10 +116,12 @@ static int comment_pkt(git_pkt **out, const char *line, size_t len)
|
|
120
116
|
|
121
117
|
static int err_pkt(git_pkt **out, const char *line, size_t len)
|
122
118
|
{
|
123
|
-
git_pkt_err *pkt;
|
119
|
+
git_pkt_err *pkt = NULL;
|
124
120
|
size_t alloclen;
|
125
121
|
|
126
122
|
/* Remove "ERR " from the line */
|
123
|
+
if (git__prefixncmp(line, len, "ERR "))
|
124
|
+
goto out_err;
|
127
125
|
line += 4;
|
128
126
|
len -= 4;
|
129
127
|
|
@@ -131,15 +129,20 @@ static int err_pkt(git_pkt **out, const char *line, size_t len)
|
|
131
129
|
GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
|
132
130
|
pkt = git__malloc(alloclen);
|
133
131
|
GITERR_CHECK_ALLOC(pkt);
|
134
|
-
|
135
132
|
pkt->type = GIT_PKT_ERR;
|
136
|
-
pkt->len =
|
133
|
+
pkt->len = len;
|
134
|
+
|
137
135
|
memcpy(pkt->error, line, len);
|
138
136
|
pkt->error[len] = '\0';
|
139
137
|
|
140
138
|
*out = (git_pkt *) pkt;
|
141
139
|
|
142
140
|
return 0;
|
141
|
+
|
142
|
+
out_err:
|
143
|
+
giterr_set(GITERR_NET, "error parsing ERR pkt-line");
|
144
|
+
git__free(pkt);
|
145
|
+
return -1;
|
143
146
|
}
|
144
147
|
|
145
148
|
static int data_pkt(git_pkt **out, const char *line, size_t len)
|
@@ -155,7 +158,7 @@ static int data_pkt(git_pkt **out, const char *line, size_t len)
|
|
155
158
|
GITERR_CHECK_ALLOC(pkt);
|
156
159
|
|
157
160
|
pkt->type = GIT_PKT_DATA;
|
158
|
-
pkt->len =
|
161
|
+
pkt->len = len;
|
159
162
|
memcpy(pkt->data, line, len);
|
160
163
|
|
161
164
|
*out = (git_pkt *) pkt;
|
@@ -176,7 +179,7 @@ static int sideband_progress_pkt(git_pkt **out, const char *line, size_t len)
|
|
176
179
|
GITERR_CHECK_ALLOC(pkt);
|
177
180
|
|
178
181
|
pkt->type = GIT_PKT_PROGRESS;
|
179
|
-
pkt->len =
|
182
|
+
pkt->len = len;
|
180
183
|
memcpy(pkt->data, line, len);
|
181
184
|
|
182
185
|
*out = (git_pkt *) pkt;
|
@@ -212,33 +215,25 @@ static int sideband_error_pkt(git_pkt **out, const char *line, size_t len)
|
|
212
215
|
*/
|
213
216
|
static int ref_pkt(git_pkt **out, const char *line, size_t len)
|
214
217
|
{
|
215
|
-
int error;
|
216
218
|
git_pkt_ref *pkt;
|
217
219
|
size_t alloclen;
|
218
220
|
|
219
|
-
|
220
|
-
giterr_set(GITERR_NET, "error parsing pkt-line");
|
221
|
-
return -1;
|
222
|
-
}
|
223
|
-
|
224
|
-
pkt = git__malloc(sizeof(git_pkt_ref));
|
221
|
+
pkt = git__calloc(1, sizeof(git_pkt_ref));
|
225
222
|
GITERR_CHECK_ALLOC(pkt);
|
226
|
-
|
227
|
-
memset(pkt, 0x0, sizeof(git_pkt_ref));
|
228
223
|
pkt->type = GIT_PKT_REF;
|
229
|
-
if ((error = git_oid_fromstr(&pkt->head.oid, line)) < 0)
|
230
|
-
goto error_out;
|
231
|
-
|
232
|
-
/* Check for a bit of consistency */
|
233
|
-
if (line[GIT_OID_HEXSZ] != ' ') {
|
234
|
-
giterr_set(GITERR_NET, "error parsing pkt-line");
|
235
|
-
error = -1;
|
236
|
-
goto error_out;
|
237
|
-
}
|
238
224
|
|
239
|
-
|
240
|
-
|
241
|
-
|
225
|
+
if (len < GIT_OID_HEXSZ || git_oid_fromstr(&pkt->head.oid, line) < 0)
|
226
|
+
goto out_err;
|
227
|
+
line += GIT_OID_HEXSZ;
|
228
|
+
len -= GIT_OID_HEXSZ;
|
229
|
+
|
230
|
+
if (git__prefixncmp(line, len, " "))
|
231
|
+
goto out_err;
|
232
|
+
line++;
|
233
|
+
len--;
|
234
|
+
|
235
|
+
if (!len)
|
236
|
+
goto out_err;
|
242
237
|
|
243
238
|
if (line[len - 1] == '\n')
|
244
239
|
--len;
|
@@ -250,36 +245,36 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len)
|
|
250
245
|
memcpy(pkt->head.name, line, len);
|
251
246
|
pkt->head.name[len] = '\0';
|
252
247
|
|
253
|
-
if (strlen(pkt->head.name) < len)
|
248
|
+
if (strlen(pkt->head.name) < len)
|
254
249
|
pkt->capabilities = strchr(pkt->head.name, '\0') + 1;
|
255
|
-
}
|
256
250
|
|
257
251
|
*out = (git_pkt *)pkt;
|
258
252
|
return 0;
|
259
253
|
|
260
|
-
|
254
|
+
out_err:
|
255
|
+
giterr_set(GITERR_NET, "error parsing REF pkt-line");
|
256
|
+
if (pkt)
|
257
|
+
git__free(pkt->head.name);
|
261
258
|
git__free(pkt);
|
262
|
-
return
|
259
|
+
return -1;
|
263
260
|
}
|
264
261
|
|
265
262
|
static int ok_pkt(git_pkt **out, const char *line, size_t len)
|
266
263
|
{
|
267
264
|
git_pkt_ok *pkt;
|
268
|
-
const char *ptr;
|
269
265
|
size_t alloc_len;
|
270
266
|
|
271
267
|
pkt = git__malloc(sizeof(*pkt));
|
272
268
|
GITERR_CHECK_ALLOC(pkt);
|
273
|
-
|
274
269
|
pkt->type = GIT_PKT_OK;
|
275
270
|
|
276
|
-
line
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
271
|
+
if (git__prefixncmp(line, len, "ok "))
|
272
|
+
goto out_err;
|
273
|
+
line += 3;
|
274
|
+
len -= 3;
|
275
|
+
|
276
|
+
if (line[len - 1] == '\n')
|
277
|
+
--len;
|
283
278
|
|
284
279
|
GITERR_CHECK_ALLOC_ADD(&alloc_len, len, 1);
|
285
280
|
pkt->ref = git__malloc(alloc_len);
|
@@ -290,12 +285,17 @@ static int ok_pkt(git_pkt **out, const char *line, size_t len)
|
|
290
285
|
|
291
286
|
*out = (git_pkt *)pkt;
|
292
287
|
return 0;
|
288
|
+
|
289
|
+
out_err:
|
290
|
+
giterr_set(GITERR_NET, "error parsing OK pkt-line");
|
291
|
+
git__free(pkt);
|
292
|
+
return -1;
|
293
293
|
}
|
294
294
|
|
295
295
|
static int ng_pkt(git_pkt **out, const char *line, size_t len)
|
296
296
|
{
|
297
297
|
git_pkt_ng *pkt;
|
298
|
-
const char *ptr;
|
298
|
+
const char *ptr, *eol;
|
299
299
|
size_t alloclen;
|
300
300
|
|
301
301
|
pkt = git__malloc(sizeof(*pkt));
|
@@ -304,8 +304,13 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
|
|
304
304
|
pkt->ref = NULL;
|
305
305
|
pkt->type = GIT_PKT_NG;
|
306
306
|
|
307
|
-
line
|
308
|
-
|
307
|
+
eol = line + len;
|
308
|
+
|
309
|
+
if (git__prefixncmp(line, len, "ng "))
|
310
|
+
goto out_err;
|
311
|
+
line += 3;
|
312
|
+
|
313
|
+
if (!(ptr = memchr(line, ' ', eol - line)))
|
309
314
|
goto out_err;
|
310
315
|
len = ptr - line;
|
311
316
|
|
@@ -317,7 +322,10 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
|
|
317
322
|
pkt->ref[len] = '\0';
|
318
323
|
|
319
324
|
line = ptr + 1;
|
320
|
-
if (
|
325
|
+
if (line >= eol)
|
326
|
+
goto out_err;
|
327
|
+
|
328
|
+
if (!(ptr = memchr(line, '\n', eol - line)))
|
321
329
|
goto out_err;
|
322
330
|
len = ptr - line;
|
323
331
|
|
@@ -342,13 +350,11 @@ static int unpack_pkt(git_pkt **out, const char *line, size_t len)
|
|
342
350
|
{
|
343
351
|
git_pkt_unpack *pkt;
|
344
352
|
|
345
|
-
GIT_UNUSED(len);
|
346
|
-
|
347
353
|
pkt = git__malloc(sizeof(*pkt));
|
348
354
|
GITERR_CHECK_ALLOC(pkt);
|
349
|
-
|
350
355
|
pkt->type = GIT_PKT_UNPACK;
|
351
|
-
|
356
|
+
|
357
|
+
if (!git__prefixncmp(line, len, "unpack ok"))
|
352
358
|
pkt->unpack_ok = 1;
|
353
359
|
else
|
354
360
|
pkt->unpack_ok = 0;
|
@@ -357,13 +363,17 @@ static int unpack_pkt(git_pkt **out, const char *line, size_t len)
|
|
357
363
|
return 0;
|
358
364
|
}
|
359
365
|
|
360
|
-
static
|
366
|
+
static int parse_len(size_t *out, const char *line, size_t linelen)
|
361
367
|
{
|
362
368
|
char num[PKT_LEN_SIZE + 1];
|
363
369
|
int i, k, error;
|
364
370
|
int32_t len;
|
365
371
|
const char *num_end;
|
366
372
|
|
373
|
+
/* Not even enough for the length */
|
374
|
+
if (linelen < PKT_LEN_SIZE)
|
375
|
+
return GIT_EBUFS;
|
376
|
+
|
367
377
|
memcpy(num, line, PKT_LEN_SIZE);
|
368
378
|
num[PKT_LEN_SIZE] = '\0';
|
369
379
|
|
@@ -381,10 +391,14 @@ static int32_t parse_len(const char *line)
|
|
381
391
|
}
|
382
392
|
}
|
383
393
|
|
384
|
-
if ((error =
|
394
|
+
if ((error = git__strntol32(&len, num, PKT_LEN_SIZE, &num_end, 16)) < 0)
|
385
395
|
return error;
|
386
396
|
|
387
|
-
|
397
|
+
if (len < 0)
|
398
|
+
return -1;
|
399
|
+
|
400
|
+
*out = (size_t) len;
|
401
|
+
return 0;
|
388
402
|
}
|
389
403
|
|
390
404
|
/*
|
@@ -401,35 +415,32 @@ static int32_t parse_len(const char *line)
|
|
401
415
|
*/
|
402
416
|
|
403
417
|
int git_pkt_parse_line(
|
404
|
-
git_pkt **
|
418
|
+
git_pkt **pkt, const char **endptr, const char *line, size_t linelen)
|
405
419
|
{
|
406
|
-
int
|
407
|
-
|
408
|
-
|
409
|
-
/* Not even enough for the length */
|
410
|
-
if (bufflen > 0 && bufflen < PKT_LEN_SIZE)
|
411
|
-
return GIT_EBUFS;
|
420
|
+
int error;
|
421
|
+
size_t len;
|
412
422
|
|
413
|
-
|
414
|
-
if (len < 0) {
|
423
|
+
if ((error = parse_len(&len, line, linelen)) < 0) {
|
415
424
|
/*
|
416
|
-
* If we fail to parse the length, it might be
|
417
|
-
* server is trying to send us the
|
425
|
+
* If we fail to parse the length, it might be
|
426
|
+
* because the server is trying to send us the
|
427
|
+
* packfile already or because we do not yet have
|
428
|
+
* enough data.
|
418
429
|
*/
|
419
|
-
if (
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
return
|
430
|
+
if (error == GIT_EBUFS)
|
431
|
+
;
|
432
|
+
else if (!git__prefixncmp(line, linelen, "PACK"))
|
433
|
+
giterr_set(GITERR_NET, "unexpected pack file");
|
434
|
+
else
|
435
|
+
giterr_set(GITERR_NET, "bad packet length");
|
436
|
+
return error;
|
426
437
|
}
|
427
438
|
|
428
439
|
/*
|
429
|
-
*
|
430
|
-
*
|
440
|
+
* Make sure there is enough in the buffer to satisfy
|
441
|
+
* this line.
|
431
442
|
*/
|
432
|
-
if (
|
443
|
+
if (linelen < len)
|
433
444
|
return GIT_EBUFS;
|
434
445
|
|
435
446
|
/*
|
@@ -452,45 +463,42 @@ int git_pkt_parse_line(
|
|
452
463
|
}
|
453
464
|
|
454
465
|
if (len == 0) { /* Flush pkt */
|
455
|
-
*
|
456
|
-
return flush_pkt(
|
466
|
+
*endptr = line;
|
467
|
+
return flush_pkt(pkt);
|
457
468
|
}
|
458
469
|
|
459
470
|
len -= PKT_LEN_SIZE; /* the encoded length includes its own size */
|
460
471
|
|
461
472
|
if (*line == GIT_SIDE_BAND_DATA)
|
462
|
-
|
473
|
+
error = data_pkt(pkt, line, len);
|
463
474
|
else if (*line == GIT_SIDE_BAND_PROGRESS)
|
464
|
-
|
475
|
+
error = sideband_progress_pkt(pkt, line, len);
|
465
476
|
else if (*line == GIT_SIDE_BAND_ERROR)
|
466
|
-
|
467
|
-
else if (!
|
468
|
-
|
469
|
-
else if (!
|
470
|
-
|
471
|
-
else if (!
|
472
|
-
|
477
|
+
error = sideband_error_pkt(pkt, line, len);
|
478
|
+
else if (!git__prefixncmp(line, len, "ACK"))
|
479
|
+
error = ack_pkt(pkt, line, len);
|
480
|
+
else if (!git__prefixncmp(line, len, "NAK"))
|
481
|
+
error = nak_pkt(pkt);
|
482
|
+
else if (!git__prefixncmp(line, len, "ERR"))
|
483
|
+
error = err_pkt(pkt, line, len);
|
473
484
|
else if (*line == '#')
|
474
|
-
|
475
|
-
else if (!
|
476
|
-
|
477
|
-
else if (!
|
478
|
-
|
479
|
-
else if (!
|
480
|
-
|
485
|
+
error = comment_pkt(pkt, line, len);
|
486
|
+
else if (!git__prefixncmp(line, len, "ok"))
|
487
|
+
error = ok_pkt(pkt, line, len);
|
488
|
+
else if (!git__prefixncmp(line, len, "ng"))
|
489
|
+
error = ng_pkt(pkt, line, len);
|
490
|
+
else if (!git__prefixncmp(line, len, "unpack"))
|
491
|
+
error = unpack_pkt(pkt, line, len);
|
481
492
|
else
|
482
|
-
|
493
|
+
error = ref_pkt(pkt, line, len);
|
483
494
|
|
484
|
-
*
|
495
|
+
*endptr = line + len;
|
485
496
|
|
486
|
-
return
|
497
|
+
return error;
|
487
498
|
}
|
488
499
|
|
489
500
|
void git_pkt_free(git_pkt *pkt)
|
490
501
|
{
|
491
|
-
if (pkt == NULL) {
|
492
|
-
return;
|
493
|
-
}
|
494
502
|
if (pkt->type == GIT_PKT_REF) {
|
495
503
|
git_pkt_ref *p = (git_pkt_ref *) pkt;
|
496
504
|
git__free(p->head.name);
|
@@ -559,7 +567,7 @@ static int buffer_want_with_caps(const git_remote_head *head, transport_smart_ca
|
|
559
567
|
git_oid_fmt(oid, &head->oid);
|
560
568
|
git_buf_printf(buf,
|
561
569
|
"%04xwant %s %s\n", (unsigned int)len, oid, git_buf_cstr(&str));
|
562
|
-
|
570
|
+
git_buf_free(&str);
|
563
571
|
|
564
572
|
GITERR_CHECK_ALLOC_BUF(buf);
|
565
573
|
|