Skip to content

Commit a2cc4de

Browse files
committed
Fix bug
1 parent e20faf8 commit a2cc4de

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lib/data/long.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ use crate::factors::TranscryptionInfo;
7878
use crate::factors::{
7979
AttributeRekeyInfo, PseudonymRekeyInfo, PseudonymizationInfo, RerandomizeFactor,
8080
};
81+
#[cfg(feature = "offline")]
82+
use crate::keys::{AttributeGlobalPublicKey, PseudonymGlobalPublicKey};
8183
use crate::keys::{
8284
AttributeSessionPublicKey, AttributeSessionSecretKey, PseudonymSessionPublicKey,
8385
PseudonymSessionSecretKey,
8486
};
85-
#[cfg(feature = "offline")]
86-
use crate::keys::{AttributeGlobalPublicKey, PseudonymGlobalPublicKey};
8787
use derive_more::{Deref, From};
8888
use rand_core::{CryptoRng, Rng};
8989
#[cfg(feature = "serde")]
@@ -1164,7 +1164,8 @@ fn to_bytes_padded_impl<T: ElGamalEncryptable>(items: &[T]) -> Result<Vec<u8>, E
11641164

11651165
if let Some(original_count) = is_external_padding_block(&last_block) {
11661166
// We have external padding, use the encoded original block count
1167-
if original_count > items.len() {
1167+
// Check for underflow: original_count must be at least 1
1168+
if original_count == 0 || original_count > items.len() {
11681169
return Err(Error::new(
11691170
ErrorKind::InvalidData,
11701171
"External padding contains invalid block count",

0 commit comments

Comments
 (0)