From 2b9fb9618ad8b2b468b0f9961f35a2b0db9d53b5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Apr 2004 06:18:40 +0000 Subject: r324: - don't reseed on every password generate - check for overflow (very unlikely) in random buffer generation (This used to be commit 548ec1efefa6f337a362cbadae74f177774e9e29) --- source4/libcli/util/smbencrypt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4') diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index a1c026a27d..a091805345 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -471,10 +471,13 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) new_pw_len = push_string(NULL, new_pw, password, sizeof(new_pw), string_flags); + if (new_pw_len > 512) { + return False; + } memcpy(&buffer[512 - new_pw_len], new_pw, new_pw_len); - generate_random_buffer((unsigned char *)buffer, 512 - new_pw_len, True); + generate_random_buffer((unsigned char *)buffer, 512 - new_pw_len, False); /* * The length of the new password is in the last 4 bytes of @@ -485,6 +488,7 @@ BOOL encode_pw_buffer(char buffer[516], const char *password, int string_flags) return True; } + /*********************************************************** decode a password buffer *new_pw_len is the length in bytes of the possibly mulitbyte -- cgit