rugged 0.28.2 → 0.28.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21ad4b245e4a45334bffaa2e1c7080decc90b4c2a9b6b8671221271ea74347f9
4
- data.tar.gz: 0a57d974cbe8c169b89786e530902ec7c6d84846e242ce85c07b41e75ba2ad38
3
+ metadata.gz: 446cc7095e381c2b5000771a5dd6d8ebccb2f73bd932354dd3e65c13b4b46110
4
+ data.tar.gz: 6233da45db5c54c03adfcfc69b403c3179cc762b0b2f8d144684532b56dc436c
5
5
  SHA512:
6
- metadata.gz: 97555ccbeff0f04035ab45326112334bfea18a8d7457d6f073926713a719f6eee81b94546d6d4bedeebffc2572bf2249e8f5d461be04a2d2a3554d4ce2611131
7
- data.tar.gz: f8260b5ff2d778cb305be6421ebe6c0db805c147df99f216ef39d6bec1abbde8c029ce81563e0088538ad610b408fb0f21e74dcd75ab3bdc225ea14ac70c3989
6
+ metadata.gz: 8a4cd776895a8cf25cfc30fa3e49cccf72e85482bf865732b68c514464046c762b2f9a8467c47cfcbde748335eac53bc15ff3d1970504ecb96df327c66c0c746
7
+ data.tar.gz: 52efde64ee141187e7dc623cf3cd8362dc8b94c82f3fabeb8314f346a8a4eb93e66566ec5da3c8e1df6175889d373e2a400aad07d0edaa8ae60d0fad1fc45ee6
@@ -4,5 +4,5 @@
4
4
  # For full terms see the included LICENSE file.
5
5
 
6
6
  module Rugged
7
- Version = VERSION = '0.28.2'
7
+ Version = VERSION = '0.28.3.1'
8
8
  end
@@ -7,10 +7,10 @@
7
7
  #ifndef INCLUDE_git_version_h__
8
8
  #define INCLUDE_git_version_h__
9
9
 
10
- #define LIBGIT2_VERSION "0.28.2"
10
+ #define LIBGIT2_VERSION "0.28.3"
11
11
  #define LIBGIT2_VER_MAJOR 0
12
12
  #define LIBGIT2_VER_MINOR 28
13
- #define LIBGIT2_VER_REVISION 2
13
+ #define LIBGIT2_VER_REVISION 3
14
14
  #define LIBGIT2_VER_PATCH 0
15
15
 
16
16
  #define LIBGIT2_SOVERSION 28
@@ -69,11 +69,15 @@ static int commit_error(git_commit_list_node *commit, const char *msg)
69
69
  static git_commit_list_node **alloc_parents(
70
70
  git_revwalk *walk, git_commit_list_node *commit, size_t n_parents)
71
71
  {
72
+ size_t bytes;
73
+
72
74
  if (n_parents <= PARENTS_PER_COMMIT)
73
75
  return (git_commit_list_node **)((char *)commit + sizeof(git_commit_list_node));
74
76
 
75
- return (git_commit_list_node **)git_pool_malloc(
76
- &walk->commit_pool, (uint32_t)(n_parents * sizeof(git_commit_list_node *)));
77
+ if (git__multiply_sizet_overflow(&bytes, n_parents, sizeof(git_commit_list_node *)))
78
+ return NULL;
79
+
80
+ return (git_commit_list_node **)git_pool_malloc(&walk->commit_pool, bytes);
77
81
  }
78
82
 
79
83
 
@@ -1111,8 +1111,15 @@ int git_config_find_system(git_buf *path)
1111
1111
 
1112
1112
  int git_config_find_programdata(git_buf *path)
1113
1113
  {
1114
+ int ret;
1115
+
1114
1116
  git_buf_sanitize(path);
1115
- return git_sysdir_find_programdata_file(path, GIT_CONFIG_FILENAME_PROGRAMDATA);
1117
+ ret = git_sysdir_find_programdata_file(path,
1118
+ GIT_CONFIG_FILENAME_PROGRAMDATA);
1119
+ if (ret != GIT_OK)
1120
+ return ret;
1121
+
1122
+ return git_path_validate_system_file_ownership(path->ptr);
1116
1123
  }
1117
1124
 
1118
1125
  int git_config__global_location(git_buf *buf)
@@ -14,6 +14,7 @@
14
14
  #include "win32/w32_buffer.h"
15
15
  #include "win32/w32_util.h"
16
16
  #include "win32/version.h"
17
+ #include <AclAPI.h>
17
18
  #else
18
19
  #include <dirent.h>
19
20
  #endif
@@ -1909,3 +1910,79 @@ extern int git_path_is_gitfile(const char *path, size_t pathlen, git_path_gitfil
1909
1910
  return -1;
1910
1911
  }
1911
1912
  }
1913
+
1914
+ int git_path_validate_system_file_ownership(const char *path)
1915
+ {
1916
+ #ifndef GIT_WIN32
1917
+ GIT_UNUSED(path);
1918
+ return GIT_OK;
1919
+ #else
1920
+ git_win32_path buf;
1921
+ PSID owner_sid;
1922
+ PSECURITY_DESCRIPTOR descriptor = NULL;
1923
+ HANDLE token;
1924
+ TOKEN_USER *info = NULL;
1925
+ DWORD err, len;
1926
+ int ret;
1927
+
1928
+ if (git_win32_path_from_utf8(buf, path) < 0)
1929
+ return -1;
1930
+
1931
+ err = GetNamedSecurityInfoW(buf, SE_FILE_OBJECT,
1932
+ OWNER_SECURITY_INFORMATION |
1933
+ DACL_SECURITY_INFORMATION,
1934
+ &owner_sid, NULL, NULL, NULL, &descriptor);
1935
+
1936
+ if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND) {
1937
+ ret = GIT_ENOTFOUND;
1938
+ goto cleanup;
1939
+ }
1940
+
1941
+ if (err != ERROR_SUCCESS) {
1942
+ git_error_set(GIT_ERROR_OS, "failed to get security information");
1943
+ ret = GIT_ERROR;
1944
+ goto cleanup;
1945
+ }
1946
+
1947
+ if (!IsValidSid(owner_sid)) {
1948
+ git_error_set(GIT_ERROR_INVALID, "programdata configuration file owner is unknown");
1949
+ ret = GIT_ERROR;
1950
+ goto cleanup;
1951
+ }
1952
+
1953
+ if (IsWellKnownSid(owner_sid, WinBuiltinAdministratorsSid) ||
1954
+ IsWellKnownSid(owner_sid, WinLocalSystemSid)) {
1955
+ ret = GIT_OK;
1956
+ goto cleanup;
1957
+ }
1958
+
1959
+ /* Obtain current user's SID */
1960
+ if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) &&
1961
+ !GetTokenInformation(token, TokenUser, NULL, 0, &len)) {
1962
+ info = git__malloc(len);
1963
+ GIT_ERROR_CHECK_ALLOC(info);
1964
+ if (!GetTokenInformation(token, TokenUser, info, len, &len)) {
1965
+ git__free(info);
1966
+ info = NULL;
1967
+ }
1968
+ }
1969
+
1970
+ /*
1971
+ * If the file is owned by the same account that is running the current
1972
+ * process, it's okay to read from that file.
1973
+ */
1974
+ if (info && EqualSid(owner_sid, info->User.Sid))
1975
+ ret = GIT_OK;
1976
+ else {
1977
+ git_error_set(GIT_ERROR_INVALID, "programdata configuration file owner is not valid");
1978
+ ret = GIT_ERROR;
1979
+ }
1980
+ free(info);
1981
+
1982
+ cleanup:
1983
+ if (descriptor)
1984
+ LocalFree(descriptor);
1985
+
1986
+ return ret;
1987
+ #endif
1988
+ }
@@ -647,4 +647,16 @@ extern bool git_path_isvalid(
647
647
  */
648
648
  int git_path_normalize_slashes(git_buf *out, const char *path);
649
649
 
650
+ /**
651
+ * Validate a system file's ownership
652
+ *
653
+ * Verify that the file in question is owned by an administrator or system
654
+ * account, or at least by the current user.
655
+ *
656
+ * This function returns 0 if successful. If the file is not owned by any of
657
+ * these, or any other if there have been problems determining the file
658
+ * ownership, it returns -1.
659
+ */
660
+ int git_path_validate_system_file_ownership(const char *path);
661
+
650
662
  #endif
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rugged
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.2
4
+ version: 0.28.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chacon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-06-18 00:00:00.000000000 Z
12
+ date: 2019-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler