rugged 0.22.2 → 0.23.0b1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/rugged/rugged.c +1 -2
- data/ext/rugged/rugged_branch_collection.c +6 -44
- data/ext/rugged/rugged_config.c +7 -3
- data/ext/rugged/rugged_diff_delta.c +1 -1
- data/ext/rugged/rugged_diff_line.c +1 -1
- data/ext/rugged/rugged_object.c +2 -2
- data/ext/rugged/rugged_reference_collection.c +12 -56
- data/ext/rugged/rugged_remote.c +4 -33
- data/ext/rugged/rugged_remote_collection.c +1 -1
- data/ext/rugged/rugged_repo.c +10 -36
- data/ext/rugged/rugged_settings.c +3 -3
- data/ext/rugged/rugged_tree.c +1 -1
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +10 -3
- data/vendor/libgit2/COPYING +15 -21
- data/vendor/libgit2/include/git2/annotated_commit.h +20 -3
- data/vendor/libgit2/include/git2/branch.h +20 -16
- data/vendor/libgit2/include/git2/checkout.h +32 -18
- data/vendor/libgit2/include/git2/cherrypick.h +2 -2
- data/vendor/libgit2/include/git2/clone.h +4 -10
- data/vendor/libgit2/include/git2/config.h +66 -12
- data/vendor/libgit2/include/git2/describe.h +3 -2
- data/vendor/libgit2/include/git2/diff.h +3 -3
- data/vendor/libgit2/include/git2/errors.h +1 -0
- data/vendor/libgit2/include/git2/filter.h +21 -5
- data/vendor/libgit2/include/git2/index.h +32 -0
- data/vendor/libgit2/include/git2/merge.h +20 -3
- data/vendor/libgit2/include/git2/oid.h +1 -1
- data/vendor/libgit2/include/git2/pack.h +13 -0
- data/vendor/libgit2/include/git2/patch.h +3 -6
- data/vendor/libgit2/include/git2/rebase.h +8 -12
- data/vendor/libgit2/include/git2/refs.h +19 -29
- data/vendor/libgit2/include/git2/remote.h +5 -11
- data/vendor/libgit2/include/git2/repository.h +44 -15
- data/vendor/libgit2/include/git2/reset.h +19 -10
- data/vendor/libgit2/include/git2/revert.h +2 -2
- data/vendor/libgit2/include/git2/submodule.h +3 -9
- data/vendor/libgit2/include/git2/sys/config.h +3 -1
- data/vendor/libgit2/include/git2/sys/filter.h +10 -2
- data/vendor/libgit2/include/git2/sys/hashsig.h +49 -22
- data/vendor/libgit2/include/git2/transport.h +1 -1
- data/vendor/libgit2/include/git2/types.h +10 -3
- data/vendor/libgit2/include/git2/version.h +3 -2
- data/vendor/libgit2/src/annotated_commit.c +28 -0
- data/vendor/libgit2/src/array.h +19 -8
- data/vendor/libgit2/src/attr.c +95 -35
- data/vendor/libgit2/src/attr_file.c +51 -17
- data/vendor/libgit2/src/attr_file.h +37 -10
- data/vendor/libgit2/src/attrcache.c +13 -7
- data/vendor/libgit2/src/attrcache.h +1 -0
- data/vendor/libgit2/src/blame.c +26 -2
- data/vendor/libgit2/src/blame_git.c +6 -2
- data/vendor/libgit2/src/blob.c +6 -8
- data/vendor/libgit2/src/branch.c +55 -43
- data/vendor/libgit2/src/buf_text.c +13 -6
- data/vendor/libgit2/src/buffer.c +110 -25
- data/vendor/libgit2/src/buffer.h +18 -0
- data/vendor/libgit2/src/checkout.c +164 -92
- data/vendor/libgit2/src/checkout.h +0 -7
- data/vendor/libgit2/src/cherrypick.c +13 -7
- data/vendor/libgit2/src/clone.c +23 -25
- data/vendor/libgit2/src/commit.c +3 -3
- data/vendor/libgit2/src/common.h +23 -1
- data/vendor/libgit2/src/config.c +137 -19
- data/vendor/libgit2/src/config.h +2 -2
- data/vendor/libgit2/src/config_cache.c +2 -1
- data/vendor/libgit2/src/config_file.c +39 -18
- data/vendor/libgit2/src/config_file.h +1 -1
- data/vendor/libgit2/src/crlf.c +1 -1
- data/vendor/libgit2/src/delta-apply.c +3 -2
- data/vendor/libgit2/src/delta.c +25 -6
- data/vendor/libgit2/src/describe.c +2 -0
- data/vendor/libgit2/src/diff.c +8 -5
- data/vendor/libgit2/src/diff_driver.c +39 -18
- data/vendor/libgit2/src/diff_file.c +1 -1
- data/vendor/libgit2/src/diff_patch.c +12 -6
- data/vendor/libgit2/src/diff_tform.c +21 -24
- data/vendor/libgit2/src/filebuf.c +14 -12
- data/vendor/libgit2/src/fileops.c +61 -18
- data/vendor/libgit2/src/fileops.h +11 -2
- data/vendor/libgit2/src/filter.c +351 -99
- data/vendor/libgit2/src/filter.h +17 -0
- data/vendor/libgit2/src/global.c +38 -9
- data/vendor/libgit2/src/hash/hash_generic.c +1 -1
- data/vendor/libgit2/src/hashsig.c +28 -16
- data/vendor/libgit2/src/ignore.c +2 -2
- data/vendor/libgit2/src/index.c +159 -42
- data/vendor/libgit2/src/index.h +29 -0
- data/vendor/libgit2/src/indexer.c +11 -2
- data/vendor/libgit2/src/integer.h +96 -0
- data/vendor/libgit2/src/iterator.c +5 -3
- data/vendor/libgit2/src/khash.h +41 -29
- data/vendor/libgit2/src/merge.c +48 -35
- data/vendor/libgit2/src/merge.h +0 -1
- data/vendor/libgit2/src/merge_file.c +13 -0
- data/vendor/libgit2/src/mwindow.c +1 -1
- data/vendor/libgit2/src/notes.c +1 -1
- data/vendor/libgit2/src/odb.c +13 -11
- data/vendor/libgit2/src/odb_loose.c +22 -10
- data/vendor/libgit2/src/odb_mempack.c +4 -2
- data/vendor/libgit2/src/offmap.h +3 -2
- data/vendor/libgit2/src/oid.c +1 -1
- data/vendor/libgit2/src/oidmap.h +2 -1
- data/vendor/libgit2/src/openssl_stream.c +6 -3
- data/vendor/libgit2/src/pack-objects.c +273 -12
- data/vendor/libgit2/src/pack-objects.h +10 -0
- data/vendor/libgit2/src/pack.c +17 -6
- data/vendor/libgit2/src/pack.h +1 -3
- data/vendor/libgit2/src/path.c +68 -38
- data/vendor/libgit2/src/pathspec.c +3 -0
- data/vendor/libgit2/src/pool.c +9 -8
- data/vendor/libgit2/src/posix.c +11 -1
- data/vendor/libgit2/src/push.c +15 -17
- data/vendor/libgit2/src/push.h +1 -6
- data/vendor/libgit2/src/rebase.c +77 -35
- data/vendor/libgit2/src/refdb_fs.c +2 -2
- data/vendor/libgit2/src/refs.c +107 -81
- data/vendor/libgit2/src/refs.h +2 -2
- data/vendor/libgit2/src/refspec.c +3 -0
- data/vendor/libgit2/src/remote.c +19 -21
- data/vendor/libgit2/src/repository.c +258 -67
- data/vendor/libgit2/src/repository.h +31 -16
- data/vendor/libgit2/src/reset.c +28 -12
- data/vendor/libgit2/src/revert.c +12 -7
- data/vendor/libgit2/src/revwalk.c +3 -5
- data/vendor/libgit2/src/revwalk.h +1 -1
- data/vendor/libgit2/src/sortedcache.c +5 -3
- data/vendor/libgit2/src/stash.c +3 -5
- data/vendor/libgit2/src/strmap.h +2 -1
- data/vendor/libgit2/src/submodule.c +5 -6
- data/vendor/libgit2/src/tag.c +7 -5
- data/vendor/libgit2/src/transaction.c +1 -1
- data/vendor/libgit2/src/transports/cred.c +5 -2
- data/vendor/libgit2/src/transports/git.c +2 -3
- data/vendor/libgit2/src/transports/local.c +15 -34
- data/vendor/libgit2/src/transports/smart.c +1 -1
- data/vendor/libgit2/src/transports/smart_pkt.c +58 -18
- data/vendor/libgit2/src/transports/smart_protocol.c +2 -2
- data/vendor/libgit2/src/transports/winhttp.c +2 -2
- data/vendor/libgit2/src/tree.c +7 -5
- data/vendor/libgit2/src/tsort.c +3 -1
- data/vendor/libgit2/src/util.c +25 -0
- data/vendor/libgit2/src/util.h +31 -27
- data/vendor/libgit2/src/vector.c +2 -7
- data/vendor/libgit2/src/win32/dir.c +5 -3
- data/vendor/libgit2/src/win32/git2.rc +8 -4
- data/vendor/libgit2/src/win32/mingw-compat.h +7 -0
- data/vendor/libgit2/src/win32/msvc-compat.h +3 -0
- data/vendor/libgit2/src/win32/posix.h +1 -3
- data/vendor/libgit2/src/win32/posix_w32.c +31 -7
- data/vendor/libgit2/src/win32/utf-conv.c +1 -3
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +5 -5
- data/vendor/libgit2/src/bswap.h +0 -97
@@ -348,7 +348,7 @@ static int local_push_update_remote_ref(
|
|
348
348
|
if (lref[0] != '\0') {
|
349
349
|
/* Create or update a ref */
|
350
350
|
error = git_reference_create(NULL, remote_repo, rref, loid,
|
351
|
-
!git_oid_iszero(roid), NULL
|
351
|
+
!git_oid_iszero(roid), NULL);
|
352
352
|
} else {
|
353
353
|
/* Delete a ref */
|
354
354
|
if ((error = git_reference_lookup(&remote_ref, remote_repo, rref)) < 0) {
|
@@ -420,7 +420,7 @@ static int local_push(
|
|
420
420
|
const git_error *last;
|
421
421
|
char *ref = spec->refspec.dst;
|
422
422
|
|
423
|
-
status = git__calloc(sizeof(push_status)
|
423
|
+
status = git__calloc(1, sizeof(push_status));
|
424
424
|
if (!status)
|
425
425
|
goto on_error;
|
426
426
|
|
@@ -513,7 +513,6 @@ static int local_download_pack(
|
|
513
513
|
git_remote_head *rhead;
|
514
514
|
unsigned int i;
|
515
515
|
int error = -1;
|
516
|
-
git_oid oid;
|
517
516
|
git_packbuilder *pack = NULL;
|
518
517
|
git_odb_writepack *writepack = NULL;
|
519
518
|
git_odb *odb = NULL;
|
@@ -539,15 +538,22 @@ static int local_download_pack(
|
|
539
538
|
if (git_object_type(obj) == GIT_OBJ_COMMIT) {
|
540
539
|
/* Revwalker includes only wanted commits */
|
541
540
|
error = git_revwalk_push(walk, &rhead->oid);
|
542
|
-
if (!git_oid_iszero(&rhead->loid))
|
541
|
+
if (!error && !git_oid_iszero(&rhead->loid)) {
|
543
542
|
error = git_revwalk_hide(walk, &rhead->loid);
|
543
|
+
if (error == GIT_ENOTFOUND)
|
544
|
+
error = 0;
|
545
|
+
}
|
544
546
|
} else {
|
545
|
-
/* Tag or some other wanted object. Add it on its own */
|
546
547
|
error = git_packbuilder_insert(pack, &rhead->oid, rhead->name);
|
547
548
|
}
|
548
549
|
git_object_free(obj);
|
550
|
+
if (error < 0)
|
551
|
+
goto cleanup;
|
549
552
|
}
|
550
553
|
|
554
|
+
if ((error = git_packbuilder_insert_walk(pack, walk)))
|
555
|
+
goto cleanup;
|
556
|
+
|
551
557
|
if ((error = git_buf_printf(&progress_info, counting_objects_fmt, git_packbuilder_object_count(pack))) < 0)
|
552
558
|
goto cleanup;
|
553
559
|
|
@@ -559,35 +565,6 @@ static int local_download_pack(
|
|
559
565
|
if ((error = git_repository_odb__weakptr(&odb, repo)) < 0)
|
560
566
|
goto cleanup;
|
561
567
|
|
562
|
-
while ((error = git_revwalk_next(&oid, walk)) == 0) {
|
563
|
-
git_commit *commit;
|
564
|
-
|
565
|
-
/* Skip commits we already have */
|
566
|
-
if (git_odb_exists(odb, &oid)) continue;
|
567
|
-
|
568
|
-
if (!git_object_lookup((git_object**)&commit, t->repo, &oid, GIT_OBJ_COMMIT)) {
|
569
|
-
const git_oid *tree_oid = git_commit_tree_id(commit);
|
570
|
-
|
571
|
-
/* Add the commit and its tree */
|
572
|
-
if ((error = git_packbuilder_insert(pack, &oid, NULL)) < 0 ||
|
573
|
-
(error = git_packbuilder_insert_tree(pack, tree_oid)) < 0) {
|
574
|
-
git_commit_free(commit);
|
575
|
-
goto cleanup;
|
576
|
-
}
|
577
|
-
|
578
|
-
git_commit_free(commit);
|
579
|
-
|
580
|
-
git_buf_clear(&progress_info);
|
581
|
-
if ((error = git_buf_printf(&progress_info, counting_objects_fmt, git_packbuilder_object_count(pack))) < 0)
|
582
|
-
goto cleanup;
|
583
|
-
|
584
|
-
if (t->progress_cb &&
|
585
|
-
(error = t->progress_cb(git_buf_cstr(&progress_info), git_buf_len(&progress_info), t->message_cb_payload)) < 0)
|
586
|
-
goto cleanup;
|
587
|
-
|
588
|
-
}
|
589
|
-
}
|
590
|
-
|
591
568
|
/* One last one with the newline */
|
592
569
|
git_buf_clear(&progress_info);
|
593
570
|
git_buf_printf(&progress_info, counting_objects_fmt, git_packbuilder_object_count(pack));
|
@@ -609,9 +586,13 @@ static int local_download_pack(
|
|
609
586
|
data.progress_payload = progress_payload;
|
610
587
|
data.writepack = writepack;
|
611
588
|
|
589
|
+
/* autodetect */
|
590
|
+
git_packbuilder_set_threads(pack, 0);
|
591
|
+
|
612
592
|
if ((error = git_packbuilder_foreach(pack, foreach_cb, &data)) != 0)
|
613
593
|
goto cleanup;
|
614
594
|
}
|
595
|
+
|
615
596
|
error = writepack->commit(writepack, stats);
|
616
597
|
|
617
598
|
cleanup:
|
@@ -380,7 +380,7 @@ int git_transport_smart(git_transport **out, git_remote *owner, void *param)
|
|
380
380
|
if (!param)
|
381
381
|
return -1;
|
382
382
|
|
383
|
-
t = git__calloc(sizeof(transport_smart)
|
383
|
+
t = git__calloc(1, sizeof(transport_smart));
|
384
384
|
GITERR_CHECK_ALLOC(t);
|
385
385
|
|
386
386
|
t->parent.version = GIT_TRANSPORT_VERSION;
|
@@ -102,8 +102,11 @@ static int pack_pkt(git_pkt **out)
|
|
102
102
|
static int comment_pkt(git_pkt **out, const char *line, size_t len)
|
103
103
|
{
|
104
104
|
git_pkt_comment *pkt;
|
105
|
+
size_t alloclen;
|
105
106
|
|
106
|
-
|
107
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_comment), len);
|
108
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
|
109
|
+
pkt = git__malloc(alloclen);
|
107
110
|
GITERR_CHECK_ALLOC(pkt);
|
108
111
|
|
109
112
|
pkt->type = GIT_PKT_COMMENT;
|
@@ -118,11 +121,15 @@ static int comment_pkt(git_pkt **out, const char *line, size_t len)
|
|
118
121
|
static int err_pkt(git_pkt **out, const char *line, size_t len)
|
119
122
|
{
|
120
123
|
git_pkt_err *pkt;
|
124
|
+
size_t alloclen;
|
121
125
|
|
122
126
|
/* Remove "ERR " from the line */
|
123
127
|
line += 4;
|
124
128
|
len -= 4;
|
125
|
-
|
129
|
+
|
130
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len);
|
131
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, alloclen, 1);
|
132
|
+
pkt = git__malloc(alloclen);
|
126
133
|
GITERR_CHECK_ALLOC(pkt);
|
127
134
|
|
128
135
|
pkt->type = GIT_PKT_ERR;
|
@@ -138,10 +145,13 @@ static int err_pkt(git_pkt **out, const char *line, size_t len)
|
|
138
145
|
static int data_pkt(git_pkt **out, const char *line, size_t len)
|
139
146
|
{
|
140
147
|
git_pkt_data *pkt;
|
148
|
+
size_t alloclen;
|
141
149
|
|
142
150
|
line++;
|
143
151
|
len--;
|
144
|
-
|
152
|
+
|
153
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len);
|
154
|
+
pkt = git__malloc(alloclen);
|
145
155
|
GITERR_CHECK_ALLOC(pkt);
|
146
156
|
|
147
157
|
pkt->type = GIT_PKT_DATA;
|
@@ -156,10 +166,13 @@ static int data_pkt(git_pkt **out, const char *line, size_t len)
|
|
156
166
|
static int sideband_progress_pkt(git_pkt **out, const char *line, size_t len)
|
157
167
|
{
|
158
168
|
git_pkt_progress *pkt;
|
169
|
+
size_t alloclen;
|
159
170
|
|
160
171
|
line++;
|
161
172
|
len--;
|
162
|
-
|
173
|
+
|
174
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, sizeof(git_pkt_progress), len);
|
175
|
+
pkt = git__malloc(alloclen);
|
163
176
|
GITERR_CHECK_ALLOC(pkt);
|
164
177
|
|
165
178
|
pkt->type = GIT_PKT_PROGRESS;
|
@@ -174,10 +187,14 @@ static int sideband_progress_pkt(git_pkt **out, const char *line, size_t len)
|
|
174
187
|
static int sideband_error_pkt(git_pkt **out, const char *line, size_t len)
|
175
188
|
{
|
176
189
|
git_pkt_err *pkt;
|
190
|
+
size_t alloc_len;
|
177
191
|
|
178
192
|
line++;
|
179
193
|
len--;
|
180
|
-
|
194
|
+
|
195
|
+
GITERR_CHECK_ALLOC_ADD(&alloc_len, sizeof(git_pkt_err), len);
|
196
|
+
GITERR_CHECK_ALLOC_ADD(&alloc_len, alloc_len, 1);
|
197
|
+
pkt = git__malloc(alloc_len);
|
181
198
|
GITERR_CHECK_ALLOC(pkt);
|
182
199
|
|
183
200
|
pkt->type = GIT_PKT_ERR;
|
@@ -197,6 +214,7 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len)
|
|
197
214
|
{
|
198
215
|
int error;
|
199
216
|
git_pkt_ref *pkt;
|
217
|
+
size_t alloclen;
|
200
218
|
|
201
219
|
pkt = git__malloc(sizeof(git_pkt_ref));
|
202
220
|
GITERR_CHECK_ALLOC(pkt);
|
@@ -220,7 +238,8 @@ static int ref_pkt(git_pkt **out, const char *line, size_t len)
|
|
220
238
|
if (line[len - 1] == '\n')
|
221
239
|
--len;
|
222
240
|
|
223
|
-
|
241
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1);
|
242
|
+
pkt->head.name = git__malloc(alloclen);
|
224
243
|
GITERR_CHECK_ALLOC(pkt->head.name);
|
225
244
|
|
226
245
|
memcpy(pkt->head.name, line, len);
|
@@ -242,6 +261,7 @@ static int ok_pkt(git_pkt **out, const char *line, size_t len)
|
|
242
261
|
{
|
243
262
|
git_pkt_ok *pkt;
|
244
263
|
const char *ptr;
|
264
|
+
size_t alloc_len;
|
245
265
|
|
246
266
|
pkt = git__malloc(sizeof(*pkt));
|
247
267
|
GITERR_CHECK_ALLOC(pkt);
|
@@ -249,10 +269,14 @@ static int ok_pkt(git_pkt **out, const char *line, size_t len)
|
|
249
269
|
pkt->type = GIT_PKT_OK;
|
250
270
|
|
251
271
|
line += 3; /* skip "ok " */
|
252
|
-
ptr = strchr(line, '\n')
|
272
|
+
if (!(ptr = strchr(line, '\n'))) {
|
273
|
+
giterr_set(GITERR_NET, "Invalid packet line");
|
274
|
+
return -1;
|
275
|
+
}
|
253
276
|
len = ptr - line;
|
254
277
|
|
255
|
-
|
278
|
+
GITERR_CHECK_ALLOC_ADD(&alloc_len, len, 1);
|
279
|
+
pkt->ref = git__malloc(alloc_len);
|
256
280
|
GITERR_CHECK_ALLOC(pkt->ref);
|
257
281
|
|
258
282
|
memcpy(pkt->ref, line, len);
|
@@ -266,6 +290,7 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
|
|
266
290
|
{
|
267
291
|
git_pkt_ng *pkt;
|
268
292
|
const char *ptr;
|
293
|
+
size_t alloclen;
|
269
294
|
|
270
295
|
pkt = git__malloc(sizeof(*pkt));
|
271
296
|
GITERR_CHECK_ALLOC(pkt);
|
@@ -273,20 +298,28 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
|
|
273
298
|
pkt->type = GIT_PKT_NG;
|
274
299
|
|
275
300
|
line += 3; /* skip "ng " */
|
276
|
-
ptr = strchr(line, ' ')
|
301
|
+
if (!(ptr = strchr(line, ' '))) {
|
302
|
+
giterr_set(GITERR_NET, "Invalid packet line");
|
303
|
+
return -1;
|
304
|
+
}
|
277
305
|
len = ptr - line;
|
278
306
|
|
279
|
-
|
307
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1);
|
308
|
+
pkt->ref = git__malloc(alloclen);
|
280
309
|
GITERR_CHECK_ALLOC(pkt->ref);
|
281
310
|
|
282
311
|
memcpy(pkt->ref, line, len);
|
283
312
|
pkt->ref[len] = '\0';
|
284
313
|
|
285
314
|
line = ptr + 1;
|
286
|
-
ptr = strchr(line, '\n')
|
315
|
+
if (!(ptr = strchr(line, '\n'))) {
|
316
|
+
giterr_set(GITERR_NET, "Invalid packet line");
|
317
|
+
return -1;
|
318
|
+
}
|
287
319
|
len = ptr - line;
|
288
320
|
|
289
|
-
|
321
|
+
GITERR_CHECK_ALLOC_ADD(&alloclen, len, 1);
|
322
|
+
pkt->msg = git__malloc(alloclen);
|
290
323
|
GITERR_CHECK_ALLOC(pkt->msg);
|
291
324
|
|
292
325
|
memcpy(pkt->msg, line, len);
|
@@ -459,7 +492,7 @@ static int buffer_want_with_caps(const git_remote_head *head, transport_smart_ca
|
|
459
492
|
{
|
460
493
|
git_buf str = GIT_BUF_INIT;
|
461
494
|
char oid[GIT_OID_HEXSZ +1] = {0};
|
462
|
-
|
495
|
+
size_t len;
|
463
496
|
|
464
497
|
/* Prefer multi_ack_detailed */
|
465
498
|
if (caps->multi_ack_detailed)
|
@@ -485,12 +518,19 @@ static int buffer_want_with_caps(const git_remote_head *head, transport_smart_ca
|
|
485
518
|
if (git_buf_oom(&str))
|
486
519
|
return -1;
|
487
520
|
|
488
|
-
len = (
|
489
|
-
|
490
|
-
|
491
|
-
|
521
|
+
len = strlen("XXXXwant ") + GIT_OID_HEXSZ + 1 /* NUL */ +
|
522
|
+
git_buf_len(&str) + 1 /* LF */;
|
523
|
+
|
524
|
+
if (len > 0xffff) {
|
525
|
+
giterr_set(GITERR_NET,
|
526
|
+
"Tried to produce packet with invalid length %d", len);
|
527
|
+
return -1;
|
528
|
+
}
|
529
|
+
|
530
|
+
git_buf_grow_by(buf, len);
|
492
531
|
git_oid_fmt(oid, &head->oid);
|
493
|
-
git_buf_printf(buf,
|
532
|
+
git_buf_printf(buf,
|
533
|
+
"%04xwant %s %s\n", (unsigned int)len, oid, git_buf_cstr(&str));
|
494
534
|
git_buf_free(&str);
|
495
535
|
|
496
536
|
return git_buf_oom(buf);
|
@@ -685,7 +685,7 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt)
|
|
685
685
|
|
686
686
|
switch (pkt->type) {
|
687
687
|
case GIT_PKT_OK:
|
688
|
-
status = git__calloc(sizeof(push_status)
|
688
|
+
status = git__calloc(1, sizeof(push_status));
|
689
689
|
GITERR_CHECK_ALLOC(status);
|
690
690
|
status->msg = NULL;
|
691
691
|
status->ref = git__strdup(((git_pkt_ok *)pkt)->ref);
|
@@ -696,7 +696,7 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt)
|
|
696
696
|
}
|
697
697
|
break;
|
698
698
|
case GIT_PKT_NG:
|
699
|
-
status = git__calloc(sizeof(push_status)
|
699
|
+
status = git__calloc(1, sizeof(push_status));
|
700
700
|
GITERR_CHECK_ALLOC(status);
|
701
701
|
status->ref = git__strdup(((git_pkt_ng *)pkt)->ref);
|
702
702
|
status->msg = git__strdup(((git_pkt_ng *)pkt)->msg);
|
@@ -1178,7 +1178,7 @@ static int winhttp_stream_alloc(winhttp_subtransport *t, winhttp_stream **stream
|
|
1178
1178
|
if (!stream)
|
1179
1179
|
return -1;
|
1180
1180
|
|
1181
|
-
s = git__calloc(sizeof(winhttp_stream)
|
1181
|
+
s = git__calloc(1, sizeof(winhttp_stream));
|
1182
1182
|
GITERR_CHECK_ALLOC(s);
|
1183
1183
|
|
1184
1184
|
s->parent.subtransport = &t->parent;
|
@@ -1329,7 +1329,7 @@ int git_smart_subtransport_http(git_smart_subtransport **out, git_transport *own
|
|
1329
1329
|
if (!out)
|
1330
1330
|
return -1;
|
1331
1331
|
|
1332
|
-
t = git__calloc(sizeof(winhttp_subtransport)
|
1332
|
+
t = git__calloc(1, sizeof(winhttp_subtransport));
|
1333
1333
|
GITERR_CHECK_ALLOC(t);
|
1334
1334
|
|
1335
1335
|
t->owner = (transport_smart *)owner;
|
data/vendor/libgit2/src/tree.c
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
#define DEFAULT_TREE_SIZE 16
|
18
18
|
#define MAX_FILEMODE_BYTES 6
|
19
19
|
|
20
|
-
GIT__USE_STRMAP
|
20
|
+
GIT__USE_STRMAP
|
21
21
|
|
22
22
|
static bool valid_filemode(const int filemode)
|
23
23
|
{
|
@@ -84,10 +84,11 @@ int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2)
|
|
84
84
|
static git_tree_entry *alloc_entry(const char *filename)
|
85
85
|
{
|
86
86
|
git_tree_entry *entry = NULL;
|
87
|
-
size_t filename_len = strlen(filename);
|
87
|
+
size_t filename_len = strlen(filename), tree_len;
|
88
88
|
|
89
|
-
|
90
|
-
|
89
|
+
if (GIT_ADD_SIZET_OVERFLOW(&tree_len, sizeof(git_tree_entry), filename_len) ||
|
90
|
+
GIT_ADD_SIZET_OVERFLOW(&tree_len, tree_len, 1) ||
|
91
|
+
!(entry = git__malloc(tree_len)))
|
91
92
|
return NULL;
|
92
93
|
|
93
94
|
memset(entry, 0x0, sizeof(git_tree_entry));
|
@@ -210,7 +211,8 @@ int git_tree_entry_dup(git_tree_entry **dest, const git_tree_entry *source)
|
|
210
211
|
|
211
212
|
assert(source);
|
212
213
|
|
213
|
-
total_size
|
214
|
+
GITERR_CHECK_ALLOC_ADD(&total_size, sizeof(git_tree_entry), source->filename_len);
|
215
|
+
GITERR_CHECK_ALLOC_ADD(&total_size, total_size, 1);
|
214
216
|
|
215
217
|
copy = git__malloc(total_size);
|
216
218
|
GITERR_CHECK_ALLOC(copy);
|
data/vendor/libgit2/src/tsort.c
CHANGED
@@ -184,7 +184,9 @@ static int check_invariant(struct tsort_run *stack, ssize_t stack_curr)
|
|
184
184
|
static int resize(struct tsort_store *store, size_t new_size)
|
185
185
|
{
|
186
186
|
if (store->alloc < new_size) {
|
187
|
-
void **tempstore
|
187
|
+
void **tempstore;
|
188
|
+
|
189
|
+
tempstore = git__reallocarray(store->storage, new_size, sizeof(void *));
|
188
190
|
|
189
191
|
/**
|
190
192
|
* Do not propagate on OOM; this will abort the sort and
|
data/vendor/libgit2/src/util.c
CHANGED
@@ -665,6 +665,31 @@ void git__insertsort_r(
|
|
665
665
|
git__free(swapel);
|
666
666
|
}
|
667
667
|
|
668
|
+
/*
|
669
|
+
* git__utf8_iterate is taken from the utf8proc project,
|
670
|
+
* http://www.public-software-group.org/utf8proc
|
671
|
+
*
|
672
|
+
* Copyright (c) 2009 Public Software Group e. V., Berlin, Germany
|
673
|
+
*
|
674
|
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
675
|
+
* copy of this software and associated documentation files (the ""Software""),
|
676
|
+
* to deal in the Software without restriction, including without limitation
|
677
|
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
678
|
+
* and/or sell copies of the Software, and to permit persons to whom the
|
679
|
+
* Software is furnished to do so, subject to the following conditions:
|
680
|
+
*
|
681
|
+
* The above copyright notice and this permission notice shall be included in
|
682
|
+
* all copies or substantial portions of the Software.
|
683
|
+
*
|
684
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
685
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
686
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
687
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
688
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
689
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
690
|
+
* DEALINGS IN THE SOFTWARE.
|
691
|
+
*/
|
692
|
+
|
668
693
|
static const int8_t utf8proc_utf8class[256] = {
|
669
694
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
670
695
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
data/vendor/libgit2/src/util.h
CHANGED
@@ -59,14 +59,13 @@ GIT_INLINE(char *) git__strdup(const char *str)
|
|
59
59
|
|
60
60
|
GIT_INLINE(char *) git__strndup(const char *str, size_t n)
|
61
61
|
{
|
62
|
-
size_t length = 0;
|
62
|
+
size_t length = 0, alloclength;
|
63
63
|
char *ptr;
|
64
64
|
|
65
65
|
length = p_strnlen(str, n);
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
if (!ptr)
|
67
|
+
if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) ||
|
68
|
+
!(ptr = git__malloc(alloclength)))
|
70
69
|
return NULL;
|
71
70
|
|
72
71
|
if (length)
|
@@ -80,7 +79,13 @@ GIT_INLINE(char *) git__strndup(const char *str, size_t n)
|
|
80
79
|
/* NOTE: This doesn't do null or '\0' checking. Watch those boundaries! */
|
81
80
|
GIT_INLINE(char *) git__substrdup(const char *start, size_t n)
|
82
81
|
{
|
83
|
-
char *ptr
|
82
|
+
char *ptr;
|
83
|
+
size_t alloclen;
|
84
|
+
|
85
|
+
if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) ||
|
86
|
+
!(ptr = git__malloc(alloclen)))
|
87
|
+
return NULL;
|
88
|
+
|
84
89
|
memcpy(ptr, start, n);
|
85
90
|
ptr[n] = '\0';
|
86
91
|
return ptr;
|
@@ -93,6 +98,26 @@ GIT_INLINE(void *) git__realloc(void *ptr, size_t size)
|
|
93
98
|
return new_ptr;
|
94
99
|
}
|
95
100
|
|
101
|
+
/**
|
102
|
+
* Similar to `git__realloc`, except that it is suitable for reallocing an
|
103
|
+
* array to a new number of elements of `nelem`, each of size `elsize`.
|
104
|
+
* The total size calculation is checked for overflow.
|
105
|
+
*/
|
106
|
+
GIT_INLINE(void *) git__reallocarray(void *ptr, size_t nelem, size_t elsize)
|
107
|
+
{
|
108
|
+
size_t newsize;
|
109
|
+
return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ?
|
110
|
+
NULL : realloc(ptr, newsize);
|
111
|
+
}
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Similar to `git__calloc`, except that it does not zero memory.
|
115
|
+
*/
|
116
|
+
GIT_INLINE(void *) git__mallocarray(size_t nelem, size_t elsize)
|
117
|
+
{
|
118
|
+
return git__reallocarray(NULL, nelem, elsize);
|
119
|
+
}
|
120
|
+
|
96
121
|
GIT_INLINE(void) git__free(void *ptr)
|
97
122
|
{
|
98
123
|
free(ptr);
|
@@ -120,27 +145,6 @@ extern int git__strtol64(int64_t *n, const char *buff, const char **end_buf, int
|
|
120
145
|
extern void git__hexdump(const char *buffer, size_t n);
|
121
146
|
extern uint32_t git__hash(const void *key, int len, uint32_t seed);
|
122
147
|
|
123
|
-
/** @return true if p fits into the range of a size_t */
|
124
|
-
GIT_INLINE(int) git__is_sizet(git_off_t p)
|
125
|
-
{
|
126
|
-
size_t r = (size_t)p;
|
127
|
-
return p == (git_off_t)r;
|
128
|
-
}
|
129
|
-
|
130
|
-
/** @return true if p fits into the range of a uint32_t */
|
131
|
-
GIT_INLINE(int) git__is_uint32(size_t p)
|
132
|
-
{
|
133
|
-
uint32_t r = (uint32_t)p;
|
134
|
-
return p == (size_t)r;
|
135
|
-
}
|
136
|
-
|
137
|
-
/** @return true if p fits into the range of an unsigned long */
|
138
|
-
GIT_INLINE(int) git__is_ulong(git_off_t p)
|
139
|
-
{
|
140
|
-
unsigned long r = (unsigned long)p;
|
141
|
-
return p == (git_off_t)r;
|
142
|
-
}
|
143
|
-
|
144
148
|
/* 32-bit cross-platform rotl */
|
145
149
|
#ifdef _MSC_VER /* use built-in method in MSVC */
|
146
150
|
# define git__rotl(v, s) (uint32_t)_rotl(v, s)
|
@@ -277,7 +281,7 @@ GIT_INLINE(int) git__fromhex(char h)
|
|
277
281
|
GIT_INLINE(int) git__ishex(const char *str)
|
278
282
|
{
|
279
283
|
unsigned i;
|
280
|
-
for (i=0; i
|
284
|
+
for (i=0; str[i] != '\0'; i++)
|
281
285
|
if (git__fromhex(str[i]) < 0)
|
282
286
|
return 0;
|
283
287
|
return 1;
|