mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
python:tests: Catch strings passed to utf16_encoded_len() with embedded nulls
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
27231a965e
commit
858f70037b
@ -30,6 +30,9 @@ import samba.tests
|
||||
def utf16_encoded_len(s: str) -> int:
|
||||
"""Return the number of bytes required to encode a string as null‐terminated
|
||||
UTF‐16."""
|
||||
if "\x00" in s:
|
||||
raise ValueError("string contains an embedded null")
|
||||
|
||||
return len(s.encode("utf-16-le")) + 2
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user