rugged 0.27.5 → 0.27.7
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 +2 -2
- data/vendor/libgit2/cmake/Modules/FindmbedTLS.cmake +93 -0
- data/vendor/libgit2/deps/http-parser/CMakeLists.txt +2 -0
- data/vendor/libgit2/include/git2.h +1 -0
- data/vendor/libgit2/include/git2/attr.h +18 -7
- data/vendor/libgit2/include/git2/blame.h +39 -22
- 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 +14 -2
- data/vendor/libgit2/include/git2/checkout.h +13 -12
- data/vendor/libgit2/include/git2/cherrypick.h +6 -4
- data/vendor/libgit2/include/git2/clone.h +8 -6
- data/vendor/libgit2/include/git2/commit.h +28 -0
- data/vendor/libgit2/include/git2/common.h +27 -0
- data/vendor/libgit2/include/git2/config.h +1 -0
- data/vendor/libgit2/include/git2/describe.h +30 -7
- data/vendor/libgit2/include/git2/diff.h +32 -22
- data/vendor/libgit2/include/git2/errors.h +1 -0
- data/vendor/libgit2/include/git2/ignore.h +2 -2
- data/vendor/libgit2/include/git2/mailmap.h +115 -0
- data/vendor/libgit2/include/git2/merge.h +10 -8
- data/vendor/libgit2/include/git2/proxy.h +9 -5
- data/vendor/libgit2/include/git2/rebase.h +7 -4
- data/vendor/libgit2/include/git2/refspec.h +17 -0
- data/vendor/libgit2/include/git2/remote.h +12 -10
- data/vendor/libgit2/include/git2/repository.h +7 -5
- data/vendor/libgit2/include/git2/revert.h +5 -3
- data/vendor/libgit2/include/git2/stash.h +11 -8
- data/vendor/libgit2/include/git2/status.h +7 -3
- data/vendor/libgit2/include/git2/submodule.h +8 -7
- data/vendor/libgit2/include/git2/sys/alloc.h +101 -0
- data/vendor/libgit2/include/git2/sys/index.h +3 -0
- data/vendor/libgit2/include/git2/sys/mempack.h +35 -35
- data/vendor/libgit2/include/git2/sys/merge.h +6 -1
- data/vendor/libgit2/include/git2/sys/path.h +55 -0
- data/vendor/libgit2/include/git2/transaction.h +1 -0
- data/vendor/libgit2/include/git2/types.h +8 -5
- data/vendor/libgit2/include/git2/version.h +2 -2
- data/vendor/libgit2/include/git2/worktree.h +46 -11
- data/vendor/libgit2/src/CMakeLists.txt +87 -15
- data/vendor/libgit2/src/alloc.c +47 -0
- data/vendor/libgit2/src/alloc.h +40 -0
- data/vendor/libgit2/src/apply.c +4 -4
- data/vendor/libgit2/src/attr.c +4 -4
- data/vendor/libgit2/src/attr_file.c +8 -7
- data/vendor/libgit2/src/attrcache.c +2 -2
- data/vendor/libgit2/src/blame.c +11 -4
- data/vendor/libgit2/src/blame.h +1 -0
- data/vendor/libgit2/src/blame_git.c +8 -5
- data/vendor/libgit2/src/blob.c +5 -5
- data/vendor/libgit2/src/branch.c +20 -20
- data/vendor/libgit2/src/buffer.c +9 -4
- data/vendor/libgit2/src/buffer.h +1 -1
- data/vendor/libgit2/src/checkout.c +33 -24
- data/vendor/libgit2/src/cherrypick.c +3 -3
- data/vendor/libgit2/src/clone.c +13 -13
- data/vendor/libgit2/src/commit.c +16 -3
- data/vendor/libgit2/src/common.h +3 -1
- data/vendor/libgit2/src/config.c +3 -3
- data/vendor/libgit2/src/config_file.c +193 -241
- data/vendor/libgit2/src/config_parse.c +89 -66
- data/vendor/libgit2/src/config_parse.h +2 -2
- data/vendor/libgit2/src/crlf.c +9 -3
- 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 +4 -3
- data/vendor/libgit2/src/diff_print.c +8 -8
- data/vendor/libgit2/src/diff_tform.c +1 -1
- data/vendor/libgit2/src/diff_xdiff.c +12 -0
- data/vendor/libgit2/src/features.h.in +2 -0
- 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 +3 -3
- data/vendor/libgit2/src/global.c +17 -12
- data/vendor/libgit2/src/hash.h +2 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.c +38 -0
- data/vendor/libgit2/src/hash/hash_mbedtls.h +20 -0
- data/vendor/libgit2/src/ignore.c +15 -20
- data/vendor/libgit2/src/index.c +77 -36
- data/vendor/libgit2/src/index.h +10 -0
- data/vendor/libgit2/src/indexer.c +9 -9
- data/vendor/libgit2/src/iterator.c +8 -8
- data/vendor/libgit2/src/khash.h +3 -1
- data/vendor/libgit2/src/mailmap.c +485 -0
- data/vendor/libgit2/src/mailmap.h +35 -0
- 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 +7 -7
- data/vendor/libgit2/src/odb_loose.c +13 -13
- data/vendor/libgit2/src/odb_pack.c +3 -3
- data/vendor/libgit2/src/pack-objects.c +2 -2
- data/vendor/libgit2/src/pack.c +5 -5
- data/vendor/libgit2/src/pack.h +1 -1
- data/vendor/libgit2/src/patch.c +1 -1
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +11 -4
- data/vendor/libgit2/src/path.c +42 -66
- data/vendor/libgit2/src/path.h +2 -72
- data/vendor/libgit2/src/pathspec.c +1 -1
- data/vendor/libgit2/src/push.c +2 -2
- data/vendor/libgit2/src/rebase.c +19 -22
- data/vendor/libgit2/src/refdb_fs.c +65 -34
- data/vendor/libgit2/src/refs.c +6 -6
- data/vendor/libgit2/src/refspec.c +30 -5
- data/vendor/libgit2/src/refspec.h +1 -1
- data/vendor/libgit2/src/remote.c +40 -40
- data/vendor/libgit2/src/repository.c +63 -59
- data/vendor/libgit2/src/reset.c +1 -1
- data/vendor/libgit2/src/revert.c +3 -3
- data/vendor/libgit2/src/revparse.c +4 -4
- data/vendor/libgit2/src/revwalk.c +44 -10
- data/vendor/libgit2/src/revwalk.h +2 -1
- data/vendor/libgit2/src/settings.c +25 -1
- data/vendor/libgit2/src/signature.c +1 -1
- data/vendor/libgit2/src/stash.c +80 -34
- data/vendor/libgit2/src/status.c +1 -1
- data/vendor/libgit2/src/stdalloc.c +120 -0
- data/vendor/libgit2/src/stdalloc.h +17 -0
- data/vendor/libgit2/src/streams/mbedtls.c +463 -0
- data/vendor/libgit2/src/streams/mbedtls.h +20 -0
- data/vendor/libgit2/src/streams/openssl.c +132 -34
- data/vendor/libgit2/src/streams/openssl.h +0 -107
- data/vendor/libgit2/src/streams/tls.c +3 -0
- data/vendor/libgit2/src/submodule.c +117 -82
- data/vendor/libgit2/src/sysdir.c +4 -4
- data/vendor/libgit2/src/tag.c +7 -7
- 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 +12 -12
- data/vendor/libgit2/src/transports/local.c +7 -7
- data/vendor/libgit2/src/transports/smart.c +17 -8
- data/vendor/libgit2/src/transports/smart.h +5 -5
- data/vendor/libgit2/src/transports/smart_pkt.c +122 -130
- data/vendor/libgit2/src/transports/smart_protocol.c +48 -38
- data/vendor/libgit2/src/transports/ssh.c +1 -1
- data/vendor/libgit2/src/transports/winhttp.c +6 -6
- data/vendor/libgit2/src/tree.c +12 -53
- data/vendor/libgit2/src/tree.h +0 -12
- data/vendor/libgit2/src/util.c +16 -0
- data/vendor/libgit2/src/util.h +12 -135
- 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 +94 -0
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +28 -75
- data/vendor/libgit2/src/worktree.c +64 -43
- data/vendor/libgit2/src/worktree.h +2 -0
- data/vendor/libgit2/src/xdiff/xdiffi.c +3 -1
- metadata +16 -2
@@ -455,7 +455,7 @@ static int winhttp_stream_connect(winhttp_stream *s)
|
|
455
455
|
|
456
456
|
/* Convert URL to wide characters */
|
457
457
|
error = git__utf8_to_16_alloc(&proxy_wide, processed_url.ptr);
|
458
|
-
|
458
|
+
git_buf_dispose(&processed_url);
|
459
459
|
if (error < 0)
|
460
460
|
goto on_error;
|
461
461
|
|
@@ -599,7 +599,7 @@ on_error:
|
|
599
599
|
winhttp_stream_close(s);
|
600
600
|
|
601
601
|
git__free(proxy_url);
|
602
|
-
|
602
|
+
git_buf_dispose(&buf);
|
603
603
|
return error;
|
604
604
|
}
|
605
605
|
|
@@ -659,12 +659,12 @@ static int write_chunk(HINTERNET request, const char *buffer, size_t len)
|
|
659
659
|
if (!WinHttpWriteData(request,
|
660
660
|
git_buf_cstr(&buf), (DWORD)git_buf_len(&buf),
|
661
661
|
&bytes_written)) {
|
662
|
-
|
662
|
+
git_buf_dispose(&buf);
|
663
663
|
giterr_set(GITERR_OS, "failed to write chunk header");
|
664
664
|
return -1;
|
665
665
|
}
|
666
666
|
|
667
|
-
|
667
|
+
git_buf_dispose(&buf);
|
668
668
|
|
669
669
|
/* Chunk body */
|
670
670
|
if (!WinHttpWriteData(request,
|
@@ -779,11 +779,11 @@ static int winhttp_connect(
|
|
779
779
|
if (git__utf8_to_16_alloc(&wide_ua, git_buf_cstr(&ua)) < 0) {
|
780
780
|
giterr_set(GITERR_OS, "unable to convert host to wide characters");
|
781
781
|
git__free(wide_host);
|
782
|
-
|
782
|
+
git_buf_dispose(&ua);
|
783
783
|
return -1;
|
784
784
|
}
|
785
785
|
|
786
|
-
|
786
|
+
git_buf_dispose(&ua);
|
787
787
|
|
788
788
|
/* Establish session */
|
789
789
|
t->session = WinHttpOpen(
|
data/vendor/libgit2/src/tree.c
CHANGED
@@ -74,14 +74,6 @@ int git_tree_entry_cmp(const git_tree_entry *e1, const git_tree_entry *e2)
|
|
74
74
|
return entry_sort_cmp(e1, e2);
|
75
75
|
}
|
76
76
|
|
77
|
-
int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2)
|
78
|
-
{
|
79
|
-
return git_path_cmp(
|
80
|
-
e1->filename, e1->filename_len, git_tree_entry__is_tree(e1),
|
81
|
-
e2->filename, e2->filename_len, git_tree_entry__is_tree(e2),
|
82
|
-
git__strncasecmp);
|
83
|
-
}
|
84
|
-
|
85
77
|
/**
|
86
78
|
* Allocate a new self-contained entry, with enough space after it to
|
87
79
|
* store the filename and the id.
|
@@ -342,41 +334,6 @@ const git_tree_entry *git_tree_entry_byid(
|
|
342
334
|
return NULL;
|
343
335
|
}
|
344
336
|
|
345
|
-
int git_tree__prefix_position(const git_tree *tree, const char *path)
|
346
|
-
{
|
347
|
-
struct tree_key_search ksearch;
|
348
|
-
size_t at_pos, path_len;
|
349
|
-
|
350
|
-
if (!path)
|
351
|
-
return 0;
|
352
|
-
|
353
|
-
path_len = strlen(path);
|
354
|
-
TREE_ENTRY_CHECK_NAMELEN(path_len);
|
355
|
-
|
356
|
-
ksearch.filename = path;
|
357
|
-
ksearch.filename_len = (uint16_t)path_len;
|
358
|
-
|
359
|
-
/* Find tree entry with appropriate prefix */
|
360
|
-
git_array_search(
|
361
|
-
&at_pos, tree->entries, &homing_search_cmp, &ksearch);
|
362
|
-
|
363
|
-
for (; at_pos < tree->entries.size; ++at_pos) {
|
364
|
-
const git_tree_entry *entry = git_array_get(tree->entries, at_pos);
|
365
|
-
if (homing_search_cmp(&ksearch, entry) < 0)
|
366
|
-
break;
|
367
|
-
}
|
368
|
-
|
369
|
-
for (; at_pos > 0; --at_pos) {
|
370
|
-
const git_tree_entry *entry =
|
371
|
-
git_array_get(tree->entries, at_pos - 1);
|
372
|
-
|
373
|
-
if (homing_search_cmp(&ksearch, entry) > 0)
|
374
|
-
break;
|
375
|
-
}
|
376
|
-
|
377
|
-
return (int)at_pos;
|
378
|
-
}
|
379
|
-
|
380
337
|
size_t git_tree_entrycount(const git_tree *tree)
|
381
338
|
{
|
382
339
|
assert(tree);
|
@@ -490,15 +447,16 @@ static int append_entry(
|
|
490
447
|
git_treebuilder *bld,
|
491
448
|
const char *filename,
|
492
449
|
const git_oid *id,
|
493
|
-
git_filemode_t filemode
|
450
|
+
git_filemode_t filemode,
|
451
|
+
bool from_tree)
|
494
452
|
{
|
495
453
|
git_tree_entry *entry;
|
496
454
|
int error = 0;
|
497
455
|
|
498
|
-
if (!valid_entry_name(bld->repo, filename))
|
456
|
+
if (!from_tree && !valid_entry_name(bld->repo, filename))
|
499
457
|
return tree_error("failed to insert entry: invalid name for a tree entry", filename);
|
500
458
|
|
501
|
-
if (git_oid_iszero(id))
|
459
|
+
if (!from_tree && git_oid_iszero(id))
|
502
460
|
return tree_error("failed to insert entry: invalid null OID for a tree entry", filename);
|
503
461
|
|
504
462
|
entry = alloc_entry(filename, strlen(filename), id);
|
@@ -596,12 +554,12 @@ static int write_tree(
|
|
596
554
|
last_comp = subdir;
|
597
555
|
}
|
598
556
|
|
599
|
-
error = append_entry(bld, last_comp, &sub_oid, S_IFDIR);
|
557
|
+
error = append_entry(bld, last_comp, &sub_oid, S_IFDIR, false);
|
600
558
|
git__free(subdir);
|
601
559
|
if (error < 0)
|
602
560
|
goto on_error;
|
603
561
|
} else {
|
604
|
-
error = append_entry(bld, filename, &entry->id, entry->mode);
|
562
|
+
error = append_entry(bld, filename, &entry->id, entry->mode, false);
|
605
563
|
if (error < 0)
|
606
564
|
goto on_error;
|
607
565
|
}
|
@@ -650,7 +608,7 @@ int git_tree__write_index(
|
|
650
608
|
}
|
651
609
|
|
652
610
|
ret = write_tree(oid, repo, index, "", 0, &shared_buf);
|
653
|
-
|
611
|
+
git_buf_dispose(&shared_buf);
|
654
612
|
|
655
613
|
if (old_ignore_case)
|
656
614
|
git_index__set_ignore_case(index, true);
|
@@ -699,7 +657,8 @@ int git_treebuilder_new(
|
|
699
657
|
if (append_entry(
|
700
658
|
bld, entry_src->filename,
|
701
659
|
entry_src->oid,
|
702
|
-
entry_src->attr
|
660
|
+
entry_src->attr,
|
661
|
+
true) < 0)
|
703
662
|
goto on_error;
|
704
663
|
}
|
705
664
|
}
|
@@ -814,7 +773,7 @@ int git_treebuilder_write(git_oid *oid, git_treebuilder *bld)
|
|
814
773
|
|
815
774
|
error = git_treebuilder_write_with_buffer(oid, bld, &buffer);
|
816
775
|
|
817
|
-
|
776
|
+
git_buf_dispose(&buffer);
|
818
777
|
return error;
|
819
778
|
}
|
820
779
|
|
@@ -1055,7 +1014,7 @@ int git_tree_walk(
|
|
1055
1014
|
error = tree_walk(
|
1056
1015
|
tree, callback, &root_path, payload, (mode == GIT_TREEWALK_PRE));
|
1057
1016
|
|
1058
|
-
|
1017
|
+
git_buf_dispose(&root_path);
|
1059
1018
|
|
1060
1019
|
return error;
|
1061
1020
|
}
|
@@ -1320,7 +1279,7 @@ cleanup:
|
|
1320
1279
|
}
|
1321
1280
|
}
|
1322
1281
|
|
1323
|
-
|
1282
|
+
git_buf_dispose(&component);
|
1324
1283
|
git_array_clear(stack);
|
1325
1284
|
git_vector_free(&entries);
|
1326
1285
|
return error;
|
data/vendor/libgit2/src/tree.h
CHANGED
@@ -39,21 +39,9 @@ GIT_INLINE(bool) git_tree_entry__is_tree(const struct git_tree_entry *e)
|
|
39
39
|
return (S_ISDIR(e->attr) && !S_ISGITLINK(e->attr));
|
40
40
|
}
|
41
41
|
|
42
|
-
extern int git_tree_entry_icmp(const git_tree_entry *e1, const git_tree_entry *e2);
|
43
|
-
|
44
42
|
void git_tree__free(void *tree);
|
45
43
|
int git_tree__parse(void *tree, git_odb_object *obj);
|
46
44
|
|
47
|
-
/**
|
48
|
-
* Lookup the first position in the tree with a given prefix.
|
49
|
-
*
|
50
|
-
* @param tree a previously loaded tree.
|
51
|
-
* @param prefix the beginning of a path to find in the tree.
|
52
|
-
* @return index of the first item at or after the given prefix.
|
53
|
-
*/
|
54
|
-
int git_tree__prefix_position(const git_tree *tree, const char *prefix);
|
55
|
-
|
56
|
-
|
57
45
|
/**
|
58
46
|
* Write a tree to the given repository
|
59
47
|
*/
|
data/vendor/libgit2/src/util.c
CHANGED
@@ -806,6 +806,22 @@ double git_time_monotonic(void)
|
|
806
806
|
return git__timer();
|
807
807
|
}
|
808
808
|
|
809
|
+
size_t git__utf8_valid_buf_length(const uint8_t *str, size_t str_len)
|
810
|
+
{
|
811
|
+
size_t offset = 0;
|
812
|
+
|
813
|
+
while (offset < str_len) {
|
814
|
+
int length = git__utf8_charlen(str + offset, str_len - offset);
|
815
|
+
|
816
|
+
if (length < 0)
|
817
|
+
break;
|
818
|
+
|
819
|
+
offset += length;
|
820
|
+
}
|
821
|
+
|
822
|
+
return offset;
|
823
|
+
}
|
824
|
+
|
809
825
|
#ifdef GIT_WIN32
|
810
826
|
int git__getenv(git_buf *out, const char *name)
|
811
827
|
{
|
data/vendor/libgit2/src/util.h
CHANGED
@@ -41,141 +41,6 @@
|
|
41
41
|
*/
|
42
42
|
#define CONST_STRLEN(x) ((sizeof(x)/sizeof(x[0])) - 1)
|
43
43
|
|
44
|
-
#if defined(GIT_MSVC_CRTDBG)
|
45
|
-
|
46
|
-
/* Enable MSVC CRTDBG memory leak reporting.
|
47
|
-
*
|
48
|
-
* We DO NOT use the "_CRTDBG_MAP_ALLOC" macro described in the MSVC
|
49
|
-
* documentation because all allocs/frees in libgit2 already go through
|
50
|
-
* the "git__" routines defined in this file. Simply using the normal
|
51
|
-
* reporting mechanism causes all leaks to be attributed to a routine
|
52
|
-
* here in util.h (ie, the actual call to calloc()) rather than the
|
53
|
-
* caller of git__calloc().
|
54
|
-
*
|
55
|
-
* Therefore, we declare a set of "git__crtdbg__" routines to replace
|
56
|
-
* the corresponding "git__" routines and re-define the "git__" symbols
|
57
|
-
* as macros. This allows us to get and report the file:line info of
|
58
|
-
* the real caller.
|
59
|
-
*
|
60
|
-
* We DO NOT replace the "git__free" routine because it needs to remain
|
61
|
-
* a function pointer because it is used as a function argument when
|
62
|
-
* setting up various structure "destructors".
|
63
|
-
*
|
64
|
-
* We also DO NOT use the "_CRTDBG_MAP_ALLOC" macro because it causes
|
65
|
-
* "free" to be remapped to "_free_dbg" and this causes problems for
|
66
|
-
* structures which define a field named "free".
|
67
|
-
*
|
68
|
-
* Finally, CRTDBG must be explicitly enabled and configured at program
|
69
|
-
* startup. See tests/main.c for an example.
|
70
|
-
*/
|
71
|
-
|
72
|
-
#include "win32/w32_crtdbg_stacktrace.h"
|
73
|
-
|
74
|
-
#define git__malloc(len) git__crtdbg__malloc(len, __FILE__, __LINE__)
|
75
|
-
#define git__calloc(nelem, elsize) git__crtdbg__calloc(nelem, elsize, __FILE__, __LINE__)
|
76
|
-
#define git__strdup(str) git__crtdbg__strdup(str, __FILE__, __LINE__)
|
77
|
-
#define git__strndup(str, n) git__crtdbg__strndup(str, n, __FILE__, __LINE__)
|
78
|
-
#define git__substrdup(str, n) git__crtdbg__substrdup(str, n, __FILE__, __LINE__)
|
79
|
-
#define git__realloc(ptr, size) git__crtdbg__realloc(ptr, size, __FILE__, __LINE__)
|
80
|
-
#define git__reallocarray(ptr, nelem, elsize) git__crtdbg__reallocarray(ptr, nelem, elsize, __FILE__, __LINE__)
|
81
|
-
#define git__mallocarray(nelem, elsize) git__crtdbg__mallocarray(nelem, elsize, __FILE__, __LINE__)
|
82
|
-
|
83
|
-
#else
|
84
|
-
|
85
|
-
/*
|
86
|
-
* Custom memory allocation wrappers
|
87
|
-
* that set error code and error message
|
88
|
-
* on allocation failure
|
89
|
-
*/
|
90
|
-
GIT_INLINE(void *) git__malloc(size_t len)
|
91
|
-
{
|
92
|
-
void *ptr = malloc(len);
|
93
|
-
if (!ptr) giterr_set_oom();
|
94
|
-
return ptr;
|
95
|
-
}
|
96
|
-
|
97
|
-
GIT_INLINE(void *) git__calloc(size_t nelem, size_t elsize)
|
98
|
-
{
|
99
|
-
void *ptr = calloc(nelem, elsize);
|
100
|
-
if (!ptr) giterr_set_oom();
|
101
|
-
return ptr;
|
102
|
-
}
|
103
|
-
|
104
|
-
GIT_INLINE(char *) git__strdup(const char *str)
|
105
|
-
{
|
106
|
-
char *ptr = strdup(str);
|
107
|
-
if (!ptr) giterr_set_oom();
|
108
|
-
return ptr;
|
109
|
-
}
|
110
|
-
|
111
|
-
GIT_INLINE(char *) git__strndup(const char *str, size_t n)
|
112
|
-
{
|
113
|
-
size_t length = 0, alloclength;
|
114
|
-
char *ptr;
|
115
|
-
|
116
|
-
length = p_strnlen(str, n);
|
117
|
-
|
118
|
-
if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) ||
|
119
|
-
!(ptr = git__malloc(alloclength)))
|
120
|
-
return NULL;
|
121
|
-
|
122
|
-
if (length)
|
123
|
-
memcpy(ptr, str, length);
|
124
|
-
|
125
|
-
ptr[length] = '\0';
|
126
|
-
|
127
|
-
return ptr;
|
128
|
-
}
|
129
|
-
|
130
|
-
/* NOTE: This doesn't do null or '\0' checking. Watch those boundaries! */
|
131
|
-
GIT_INLINE(char *) git__substrdup(const char *start, size_t n)
|
132
|
-
{
|
133
|
-
char *ptr;
|
134
|
-
size_t alloclen;
|
135
|
-
|
136
|
-
if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) ||
|
137
|
-
!(ptr = git__malloc(alloclen)))
|
138
|
-
return NULL;
|
139
|
-
|
140
|
-
memcpy(ptr, start, n);
|
141
|
-
ptr[n] = '\0';
|
142
|
-
return ptr;
|
143
|
-
}
|
144
|
-
|
145
|
-
GIT_INLINE(void *) git__realloc(void *ptr, size_t size)
|
146
|
-
{
|
147
|
-
void *new_ptr = realloc(ptr, size);
|
148
|
-
if (!new_ptr) giterr_set_oom();
|
149
|
-
return new_ptr;
|
150
|
-
}
|
151
|
-
|
152
|
-
/**
|
153
|
-
* Similar to `git__realloc`, except that it is suitable for reallocing an
|
154
|
-
* array to a new number of elements of `nelem`, each of size `elsize`.
|
155
|
-
* The total size calculation is checked for overflow.
|
156
|
-
*/
|
157
|
-
GIT_INLINE(void *) git__reallocarray(void *ptr, size_t nelem, size_t elsize)
|
158
|
-
{
|
159
|
-
size_t newsize;
|
160
|
-
return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ?
|
161
|
-
NULL : realloc(ptr, newsize);
|
162
|
-
}
|
163
|
-
|
164
|
-
/**
|
165
|
-
* Similar to `git__calloc`, except that it does not zero memory.
|
166
|
-
*/
|
167
|
-
GIT_INLINE(void *) git__mallocarray(size_t nelem, size_t elsize)
|
168
|
-
{
|
169
|
-
return git__reallocarray(NULL, nelem, elsize);
|
170
|
-
}
|
171
|
-
|
172
|
-
#endif /* !MSVC_CTRDBG */
|
173
|
-
|
174
|
-
GIT_INLINE(void) git__free(void *ptr)
|
175
|
-
{
|
176
|
-
free(ptr);
|
177
|
-
}
|
178
|
-
|
179
44
|
#define STRCMP_CASESELECT(IGNORE_CASE, STR1, STR2) \
|
180
45
|
((IGNORE_CASE) ? strcasecmp((STR1), (STR2)) : strcmp((STR1), (STR2)))
|
181
46
|
|
@@ -453,6 +318,16 @@ extern size_t git__unescape(char *str);
|
|
453
318
|
*/
|
454
319
|
extern int git__utf8_iterate(const uint8_t *str, int str_len, int32_t *dst);
|
455
320
|
|
321
|
+
/*
|
322
|
+
* Iterate through an UTF-8 string and stops after finding any invalid UTF-8
|
323
|
+
* codepoints.
|
324
|
+
*
|
325
|
+
* @param str string to scan
|
326
|
+
* @param str_len size of the string
|
327
|
+
* @return length in bytes of the string that contains valid data
|
328
|
+
*/
|
329
|
+
extern size_t git__utf8_valid_buf_length(const uint8_t *str, size_t str_len);
|
330
|
+
|
456
331
|
/*
|
457
332
|
* Safely zero-out memory, making sure that the compiler
|
458
333
|
* doesn't optimize away the operation.
|
@@ -543,4 +418,6 @@ GIT_INLINE(double) git__timer(void)
|
|
543
418
|
|
544
419
|
extern int git__getenv(git_buf *out, const char *name);
|
545
420
|
|
421
|
+
#include "alloc.h"
|
422
|
+
|
546
423
|
#endif
|
@@ -158,7 +158,7 @@ static int win32_find_existing_dirs(
|
|
158
158
|
}
|
159
159
|
}
|
160
160
|
|
161
|
-
|
161
|
+
git_buf_dispose(&buf);
|
162
162
|
|
163
163
|
return (git_buf_oom(out) ? -1 : 0);
|
164
164
|
}
|
@@ -185,7 +185,7 @@ int git_win32__find_system_dirs(git_buf *out, const wchar_t *subdir)
|
|
185
185
|
&buf, HKEY_LOCAL_MACHINE, REG_MSYSGIT_INSTALL, subdir) && buf.size)
|
186
186
|
git_buf_join(out, GIT_PATH_LIST_SEPARATOR, out->ptr, buf.ptr);
|
187
187
|
|
188
|
-
|
188
|
+
git_buf_dispose(&buf);
|
189
189
|
|
190
190
|
return (git_buf_oom(out) ? -1 : 0);
|
191
191
|
}
|
@@ -832,7 +832,7 @@ int p_mkstemp(char *tmp_path)
|
|
832
832
|
return -1;
|
833
833
|
#endif
|
834
834
|
|
835
|
-
return p_open(tmp_path, O_RDWR | O_CREAT | O_EXCL, 0744);
|
835
|
+
return p_open(tmp_path, O_RDWR | O_CREAT | O_EXCL, 0744); /* -V536 */
|
836
836
|
}
|
837
837
|
|
838
838
|
int p_access(const char* path, mode_t mode)
|
@@ -71,6 +71,99 @@ static bool g_limit_reached = false; /* had allocs after we filled row table */
|
|
71
71
|
static unsigned int g_checkpoint_id = 0; /* to better label leak checkpoints */
|
72
72
|
static bool g_transient_leaks_since_mark = false; /* payload for hook */
|
73
73
|
|
74
|
+
static void *crtdbg__malloc(size_t len, const char *file, int line)
|
75
|
+
{
|
76
|
+
void *ptr = _malloc_dbg(len, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
77
|
+
if (!ptr) giterr_set_oom();
|
78
|
+
return ptr;
|
79
|
+
}
|
80
|
+
|
81
|
+
static void *crtdbg__calloc(size_t nelem, size_t elsize, const char *file, int line)
|
82
|
+
{
|
83
|
+
void *ptr = _calloc_dbg(nelem, elsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
84
|
+
if (!ptr) giterr_set_oom();
|
85
|
+
return ptr;
|
86
|
+
}
|
87
|
+
|
88
|
+
static char *crtdbg__strdup(const char *str, const char *file, int line)
|
89
|
+
{
|
90
|
+
char *ptr = _strdup_dbg(str, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
91
|
+
if (!ptr) giterr_set_oom();
|
92
|
+
return ptr;
|
93
|
+
}
|
94
|
+
|
95
|
+
static char *crtdbg__strndup(const char *str, size_t n, const char *file, int line)
|
96
|
+
{
|
97
|
+
size_t length = 0, alloclength;
|
98
|
+
char *ptr;
|
99
|
+
|
100
|
+
length = p_strnlen(str, n);
|
101
|
+
|
102
|
+
if (GIT_ADD_SIZET_OVERFLOW(&alloclength, length, 1) ||
|
103
|
+
!(ptr = crtdbg__malloc(alloclength, file, line)))
|
104
|
+
return NULL;
|
105
|
+
|
106
|
+
if (length)
|
107
|
+
memcpy(ptr, str, length);
|
108
|
+
|
109
|
+
ptr[length] = '\0';
|
110
|
+
|
111
|
+
return ptr;
|
112
|
+
}
|
113
|
+
|
114
|
+
static char *crtdbg__substrdup(const char *start, size_t n, const char *file, int line)
|
115
|
+
{
|
116
|
+
char *ptr;
|
117
|
+
size_t alloclen;
|
118
|
+
|
119
|
+
if (GIT_ADD_SIZET_OVERFLOW(&alloclen, n, 1) ||
|
120
|
+
!(ptr = crtdbg__malloc(alloclen, file, line)))
|
121
|
+
return NULL;
|
122
|
+
|
123
|
+
memcpy(ptr, start, n);
|
124
|
+
ptr[n] = '\0';
|
125
|
+
return ptr;
|
126
|
+
}
|
127
|
+
|
128
|
+
static void *crtdbg__realloc(void *ptr, size_t size, const char *file, int line)
|
129
|
+
{
|
130
|
+
void *new_ptr = _realloc_dbg(ptr, size, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
131
|
+
if (!new_ptr) giterr_set_oom();
|
132
|
+
return new_ptr;
|
133
|
+
}
|
134
|
+
|
135
|
+
static void *crtdbg__reallocarray(void *ptr, size_t nelem, size_t elsize, const char *file, int line)
|
136
|
+
{
|
137
|
+
size_t newsize;
|
138
|
+
|
139
|
+
return GIT_MULTIPLY_SIZET_OVERFLOW(&newsize, nelem, elsize) ?
|
140
|
+
NULL : _realloc_dbg(ptr, newsize, _NORMAL_BLOCK, git_win32__crtdbg_stacktrace(1,file), line);
|
141
|
+
}
|
142
|
+
|
143
|
+
static void *crtdbg__mallocarray(size_t nelem, size_t elsize, const char *file, int line)
|
144
|
+
{
|
145
|
+
return crtdbg__reallocarray(NULL, nelem, elsize, file, line);
|
146
|
+
}
|
147
|
+
|
148
|
+
static void crtdbg__free(void *ptr)
|
149
|
+
{
|
150
|
+
free(ptr);
|
151
|
+
}
|
152
|
+
|
153
|
+
int git_win32_crtdbg_init_allocator(git_allocator *allocator)
|
154
|
+
{
|
155
|
+
allocator->gmalloc = crtdbg__malloc;
|
156
|
+
allocator->gcalloc = crtdbg__calloc;
|
157
|
+
allocator->gstrdup = crtdbg__strdup;
|
158
|
+
allocator->gstrndup = crtdbg__strndup;
|
159
|
+
allocator->gsubstrdup = crtdbg__substrdup;
|
160
|
+
allocator->grealloc = crtdbg__realloc;
|
161
|
+
allocator->greallocarray = crtdbg__reallocarray;
|
162
|
+
allocator->gmallocarray = crtdbg__mallocarray;
|
163
|
+
allocator->gfree = crtdbg__free;
|
164
|
+
return 0;
|
165
|
+
}
|
166
|
+
|
74
167
|
/**
|
75
168
|
* Compare function for bsearch on g_cs_index table.
|
76
169
|
*/
|
@@ -341,4 +434,5 @@ const char *git_win32__crtdbg_stacktrace(int skip, const char *file)
|
|
341
434
|
|
342
435
|
return result;
|
343
436
|
}
|
437
|
+
|
344
438
|
#endif
|