Skip to content

Commit 37bb46f

Browse files
stevenjohnstonekddnewton
authored andcommitted
Avoid reading out-of-bounds in pm_strnstr
Fixes #3738.
1 parent 2260da9 commit 37bb46f

2 files changed

Lines changed: 2 additions & 42 deletions

File tree

.github/workflows/rust-bindings.yml

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ jobs:
4141
~/.cargo/registry
4242
~/.cargo/git
4343
target
44-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
45-
restore-keys: |
46-
${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
47-
${{ runner.os }}-cargo
44+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
4845
- name: Run tests
4946
run: bundle exec rake cargo:test
5047

@@ -76,9 +73,6 @@ jobs:
7673
~/.cargo/git
7774
target
7875
key: ${{ runner.os }}-cargo--${{ hashFiles('**/Cargo.toml') }}
79-
restore-keys: |
80-
${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
81-
${{ runner.os }}-cargo
8276
- name: rake cargo:build
8377
run: bundle exec rake cargo:build
8478
- name: rake cargo:lint
@@ -107,37 +101,3 @@ jobs:
107101
components: "rust-src"
108102
- name: Test with sanitizer
109103
run: bundle exec rake cargo:sanitize:${{ matrix.sanitizer }}
110-
111-
# We need to figure out what to do here. When you run publish it checks
112-
# against the latest version published to crates, which means if we have any
113-
# breaking changes in the bindings then this fails.
114-
#
115-
# publish:
116-
# name: cargo:publish
117-
# strategy:
118-
# fail-fast: false
119-
# runs-on: ubuntu-latest
120-
# steps:
121-
# - uses: actions/checkout@v3
122-
# - name: Set up Ruby
123-
# uses: ruby/setup-ruby@v1
124-
# with:
125-
# ruby-version: head
126-
# bundler-cache: true
127-
# - name: Set up Rust
128-
# uses: dtolnay/rust-toolchain@master
129-
# with:
130-
# toolchain: "1.71.1"
131-
# targets: wasm32-wasip1
132-
# - uses: actions/cache@v4
133-
# with:
134-
# path: |
135-
# ~/.cargo/registry
136-
# ~/.cargo/git
137-
# target
138-
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
139-
# restore-keys: |
140-
# ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
141-
# ${{ runner.os }}-cargo
142-
# - name: Publish crates (dry-run)
143-
# run: bundle exec rake cargo:publish:dry

src/prism.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22639,7 +22639,7 @@ static const char *
2263922639
pm_strnstr(const char *big, const char *little, size_t big_length) {
2264022640
size_t little_length = strlen(little);
2264122641

22642-
for (const char *big_end = big + big_length; big < big_end; big++) {
22642+
for (const char *max = big + big_length - little_length; big <= max; big++) {
2264322643
if (*big == *little && memcmp(big, little, little_length) == 0) return big;
2264422644
}
2264522645

0 commit comments

Comments
 (0)