capng_c 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bce3b9c0ad260ea018498a3b20f5906b79f8796cb791ba05417071ab9dfa32f4
4
- data.tar.gz: e324f852c0f4433aa9572b2bfda44f4ab3b59ac0d8afb77fadd13ac9f76f53a8
3
+ metadata.gz: 0105fa2095d7aa7ae42d367d00931c5c0ddf7b3a008b15b973bb830e6c68c3e1
4
+ data.tar.gz: 8a23e8b4f859ee8299a79790f45809c55d776c650635d9a5a3dc84e73fb6eab1
5
5
  SHA512:
6
- metadata.gz: 45162d9090edd42d30626a9832ef1c970c45f78dfa3a77f7fea5a1184881d8a22bfaa0cc3c6e25eaf66e461cf1b09557a655b05b3789dcc9bd5a6f195b31e6b0
7
- data.tar.gz: 1c4c28132d99e46afc10c49a5dcba7574e904ffa357bfca622da34bdf8e4ed614a8daecbb5144b1d756ba65b857176ede2bbd562c808d8660cd776d635e4ea6d
6
+ metadata.gz: d3be8cd98b0d17043f5988d156118d068ea3e1e96a605b93f5e676300bb7d093ff9b2cc22ac211dc19dff042e3a1af2a415867ac9454dab4b86739ac98d460d3
7
+ data.tar.gz: 2c3892a0c6a6e6a5ab52c1d175bf93e4451d1d12fb94bc8c8e698e453465b1d5e9954eb782d16236eb28a100abef673298e48e714bf6a45359b0b3a3b2ed5987
@@ -0,0 +1,23 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'monthly'
7
+ groups:
8
+ # PR: "Security update [package] from [old] to [new]"
9
+ # This PR should be merged in hurry
10
+ security-updates:
11
+ applies-to: security-updates
12
+ patterns:
13
+ - '*'
14
+
15
+ # PR: "Bump [package] from [old] to [new]"
16
+ # No need to be merged this PR in hurry. It is enough to merge
17
+ # once in a month.
18
+ monthly-updates:
19
+ applies-to: version-updates
20
+ patterns:
21
+ - '*'
22
+ # Allow to create PR both of security and normal updates.
23
+ open-pull-requests-limit: 1
@@ -24,7 +24,7 @@ jobs:
24
24
  test-script: ci/apt-test.sh
25
25
  runs-on: ubuntu-latest
26
26
  steps:
27
- - uses: actions/checkout@master
27
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
28
28
  - name: rake compile & rake test
29
29
  run: |
30
30
  docker run \
@@ -32,4 +32,4 @@ jobs:
32
32
  --tty \
33
33
  --volume ${PWD}:/capng \
34
34
  ${{ matrix.test-docker-image }} \
35
- /capng/${{ matrix.test-script }}
35
+ /capng/${{ matrix.test-script }}
@@ -1,24 +1,36 @@
1
1
  name: Multiple Ruby version tests
2
2
  on:
3
- - push
4
- - pull_request
3
+ push:
4
+ branches: [main]
5
+ pull_request:
6
+ branches: [main]
7
+ schedule:
8
+ - cron: '0 0 1 * *'
5
9
  jobs:
10
+ ruby-versions:
11
+ uses: ruby/actions/.github/workflows/ruby_versions.yml@master
12
+ with:
13
+ engine: cruby
14
+ min_version: 2.5
6
15
  build:
16
+ needs: ruby-versions
7
17
  runs-on: ${{ matrix.os }}
8
18
  strategy:
9
19
  fail-fast: false
10
20
  matrix:
11
- ruby: [ '2.5', '2.6' , '2.7', '3.0', '3.1', '3.2', '3.3', '3.4' ]
21
+ ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
22
+ exclude:
23
+ - ruby: head
12
24
  os:
13
25
  - ubuntu-latest
14
26
  name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
15
27
  steps:
16
- - uses: actions/checkout@v2
28
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
17
29
  - name: Install dependencies
18
30
  run: |
19
31
  sudo apt update
20
32
  sudo apt -V install libcap-ng-dev
21
- - uses: ruby/setup-ruby@v1
33
+ - uses: ruby/setup-ruby@95ef2b042f9d7a56d8268cba8559e2842e2ad01b # v1.321.0
22
34
  with:
23
35
  ruby-version: ${{ matrix.ruby }}
24
36
  - name: unit testing
@@ -28,7 +28,7 @@ jobs:
28
28
  test-script: ci/yum-test.sh
29
29
  runs-on: ubuntu-latest
30
30
  steps:
31
- - uses: actions/checkout@master
31
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
32
32
  - name: rake compile & rake test
33
33
  run: |
34
34
  docker run \
data/Gemfile CHANGED
@@ -4,3 +4,7 @@ source "https://rubygems.org"
4
4
  gemspec
5
5
 
6
6
  gem "irb"
7
+
8
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') && RUBY_PLATFORM.include?('linux')
9
+ gem 'ruby_memcheck', '~> 3.0'
10
+ end
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Capng_c
2
2
 
3
- ![Multiple Ruby version tests](https://github.com/fluent-plugins-nursery/capng_c/workflows/Multiple%20Ruby%20version%20tests/badge.svg?branch=main)
4
- ![Apt based Linux](https://github.com/fluent-plugins-nursery/capng_c/workflows/Apt%20based%20Linux/badge.svg?branch=main)
5
- ![Yum based Linux](https://github.com/fluent-plugins-nursery/capng_c/workflows/Yum%20based%20Linux/badge.svg?branch=main)
3
+ [![Multiple Ruby version tests](https://github.com/fluent-plugins-nursery/capng_c/actions/workflows/linux.yml/badge.svg)](https://github.com/fluent-plugins-nursery/capng_c/actions/workflows/linux.yml)
4
+ [![Apt based Linux](https://github.com/fluent-plugins-nursery/capng_c/actions/workflows/apt.yml/badge.svg)](https://github.com/fluent-plugins-nursery/capng_c/actions/workflows/apt.yml)
5
+ [![Yum based Linux](https://github.com/fluent-plugins-nursery/capng_c/actions/workflows/yum.yml/badge.svg)](https://github.com/fluent-plugins-nursery/capng_c/actions/workflows/yum.yml)
6
6
 
7
7
  libcap-ng bindings for Ruby.
8
8
 
data/Rakefile CHANGED
@@ -18,4 +18,11 @@ end
18
18
 
19
19
  CLEAN.include('lib/capng/capng.*')
20
20
 
21
+ if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0') && RUBY_PLATFORM.include?('linux')
22
+ require 'ruby_memcheck'
23
+ namespace :test do
24
+ RubyMemcheck::TestTask.new(valgrind: :compile)
25
+ end
26
+ end
27
+
21
28
  task :default => [:clobber, :compile, :test]
data/capng_c.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.extensions = ["ext/capng/extconf.rb"]
29
29
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4".freeze)
30
30
 
31
- spec.add_development_dependency "bundler", [">= 1.16", "< 3"]
31
+ spec.add_development_dependency "bundler"
32
32
  spec.add_development_dependency "rake", "~> 13.0"
33
33
  spec.add_development_dependency "rake-compiler", "~> 1.0"
34
34
  spec.add_development_dependency "test-unit", "~> 3.3.3"
data/ext/capng/capng.c CHANGED
@@ -75,7 +75,7 @@ capng_get_file_descriptor(VALUE rb_file)
75
75
  #else
76
76
  rb_io_t* fptr = NULL;
77
77
 
78
- fptr = RFILE(rb_file)->fptr;
78
+ GetOpenFile(rb_file, fptr);
79
79
  return fptr->fd;
80
80
  #endif
81
81
  }
data/ext/capng/state.c CHANGED
@@ -52,7 +52,14 @@ capng_state_free(void* ptr)
52
52
  {
53
53
  struct CapNGState* state = (struct CapNGState*)ptr;
54
54
  if (state) {
55
- state->state = NULL;
55
+ /* Release any saved libcap-ng state that was never restored, otherwise the
56
+ * heap block returned by capng_save_state() leaks on GC. capng_c never
57
+ * stages additional groups, so the saved state owns no nested allocations
58
+ * and a plain free() fully releases it. */
59
+ if (state->state) {
60
+ free(state->state);
61
+ state->state = NULL;
62
+ }
56
63
  }
57
64
 
58
65
  xfree(ptr);
@@ -95,12 +102,16 @@ static VALUE
95
102
  rb_capng_state_save(VALUE self)
96
103
  {
97
104
  struct CapNGState* capng_state;
98
- void* state = NULL;
99
105
 
100
106
  TypedData_Get_Struct(self, struct CapNGState, &rb_capng_state_type, capng_state);
101
107
 
102
- state = capng_save_state();
103
- capng_state->state = state;
108
+ /* Free any previously saved state so repeated #save does not leak. */
109
+ if (capng_state->state) {
110
+ free(capng_state->state);
111
+ capng_state->state = NULL;
112
+ }
113
+
114
+ capng_state->state = capng_save_state();
104
115
 
105
116
  return Qnil;
106
117
  }
@@ -116,12 +127,15 @@ static VALUE
116
127
  rb_capng_state_restore(VALUE self)
117
128
  {
118
129
  struct CapNGState* capng_state;
119
- void* state = NULL;
120
130
 
121
131
  TypedData_Get_Struct(self, struct CapNGState, &rb_capng_state_type, capng_state);
122
132
 
123
- state = capng_state->state;
124
- capng_restore_state(&state);
133
+ /* Pass the struct field itself so capng_restore_state() frees the block and
134
+ * resets our pointer to NULL. Passing a local copy (the previous behaviour)
135
+ * left capng_state->state dangling, causing a use-after-free / double-free on
136
+ * a second #restore. With the field NULLed, a repeated #restore is a safe
137
+ * no-op because libcap-ng ignores a NULL saved state. */
138
+ capng_restore_state(&capng_state->state);
125
139
 
126
140
  return Qnil;
127
141
  }
data/lib/capng/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class CapNG
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capng_c
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Hatake
@@ -15,20 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '1.16'
19
- - - "<"
20
- - !ruby/object:Gem::Version
21
- version: '3'
18
+ version: '0'
22
19
  type: :development
23
20
  prerelease: false
24
21
  version_requirements: !ruby/object:Gem::Requirement
25
22
  requirements:
26
23
  - - ">="
27
24
  - !ruby/object:Gem::Version
28
- version: '1.16'
29
- - - "<"
30
- - !ruby/object:Gem::Version
31
- version: '3'
25
+ version: '0'
32
26
  - !ruby/object:Gem::Dependency
33
27
  name: rake
34
28
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +88,7 @@ extensions:
94
88
  extra_rdoc_files: []
95
89
  files:
96
90
  - ".clang-format"
91
+ - ".github/dependabot.yml"
97
92
  - ".github/workflows/apt.yml"
98
93
  - ".github/workflows/linux.yml"
99
94
  - ".github/workflows/yum.yml"
@@ -147,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
142
  - !ruby/object:Gem::Version
148
143
  version: '0'
149
144
  requirements: []
150
- rubygems_version: 3.6.9
145
+ rubygems_version: 4.0.16
151
146
  specification_version: 4
152
147
  summary: libcap-ng bindings for Ruby.
153
148
  test_files: []