diff options
author | Vincent Ambo <mail@tazj.in> | 2024-08-16T16·50+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-08-19T11·50+0000 |
commit | 9aa1c2dd197a2c93e633bddd010dc76814e784fc (patch) | |
tree | b5956acb69c06c277f086edd04b2c94c4050850d /users/tazjin/german-string | |
parent | d8640b6e67eba2e219b34da86df6842928ac87ee (diff) |
fix(tazjin/german-string): add maximum length check r/8525
Change-Id: I4fd9b2a31749d65632b662807c4e703a9df9ec9e Reviewed-on: https://cl.tvl.fyi/c/depot/+/12237 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'users/tazjin/german-string')
-rw-r--r-- | users/tazjin/german-string/src/lib.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/users/tazjin/german-string/src/lib.rs b/users/tazjin/german-string/src/lib.rs index 9aca9c72b8e9..eb6d02f29131 100644 --- a/users/tazjin/german-string/src/lib.rs +++ b/users/tazjin/german-string/src/lib.rs @@ -38,6 +38,10 @@ impl GermanString { // strings are destroyed when the object is destroyed. Persistent strings // are not supported yet. pub fn new_transient(bytes: &[u8]) -> GermanString { + if bytes.len() > u32::MAX as usize { + panic!("GermanString maximum length is {} bytes", u32::MAX); + } + if bytes.len() <= 12 { let mut s = GSSmall { len: bytes.len() as u32, |