Skip to content

Commit

Permalink
block-buffer: fix unsoundness triggered by zero block size (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Mar 9, 2023
1 parent aeda63e commit 6d35952
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpufeatures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
strategy:
matrix:
toolchain:
- 1.40.0 # MSRV
# - 1.40.0 # MSRV
- stable
runs-on: macos-latest
steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/zeroize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ jobs:
rust: stable

# 64-bit macOS x86_64
- target: x86_64-apple-darwin
platform: macos-latest
rust: 1.51.0 # MSRV
# - target: x86_64-apple-darwin
# platform: macos-latest
# rust: 1.51.0 # MSRV
- target: x86_64-apple-darwin
platform: macos-latest
rust: stable
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions block-buffer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.10.4 (2023-03-09)
### Fixed
- Unsoundness triggered by zero block size ([#844])

[#844]: https://github.com/RustCrypto/utils/pull/844

## 0.10.3 (2022-09-04)
### Added
- `try_new` method ([#799])
Expand Down
2 changes: 1 addition & 1 deletion block-buffer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "block-buffer"
version = "0.10.3"
version = "0.10.4"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
description = "Buffer type for block processing of data"
Expand Down
6 changes: 6 additions & 0 deletions block-buffer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ where
Kind: BufferKind,
{
fn default() -> Self {
if BlockSize::USIZE == 0 {
panic!("Block size can not be equal to zero");
}
Self {
buffer: Default::default(),
pos: 0,
Expand Down Expand Up @@ -113,6 +116,9 @@ where
/// Returns an error if slice length is not valid for used buffer kind.
#[inline(always)]
pub fn try_new(buf: &[u8]) -> Result<Self, Error> {
if BlockSize::USIZE == 0 {
panic!("Block size can not be equal to zero");
}
let pos = buf.len();
if !Kind::invariant(pos, BlockSize::USIZE) {
return Err(Error);
Expand Down

0 comments on commit 6d35952

Please sign in to comment.