summaryrefslogtreecommitdiffstats
path: root/source/libsmb/smbencrypt.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-12 15:02:50 -0800
committerJeremy Allison <jra@samba.org>2007-11-12 15:02:50 -0800
commiteaf14c701b08e9eff5b94bf57af68cb29142d7fc (patch)
treeef7f3d96b5a0fb701b4217c55eaa730c68338a83 /source/libsmb/smbencrypt.c
parent5d1d650d192d4782421b5c3c2be1b632d4318279 (diff)
downloadsamba-eaf14c701b08e9eff5b94bf57af68cb29142d7fc.tar.gz
samba-eaf14c701b08e9eff5b94bf57af68cb29142d7fc.tar.xz
samba-eaf14c701b08e9eff5b94bf57af68cb29142d7fc.zip
Remove all pstrings from smbd/chgpasswd.c.
Jeremy.
Diffstat (limited to 'source/libsmb/smbencrypt.c')
-rw-r--r--source/libsmb/smbencrypt.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/source/libsmb/smbencrypt.c b/source/libsmb/smbencrypt.c
index 20eddff7221..77ff063cb92 100644
--- a/source/libsmb/smbencrypt.c
+++ b/source/libsmb/smbencrypt.c
@@ -522,12 +522,17 @@ bool encode_pw_buffer(uint8 buffer[516], const char *password, int string_flags)
returned password including termination.
************************************************************/
-bool decode_pw_buffer(uint8 in_buffer[516], char *new_pwrd,
- int new_pwrd_size, uint32 *new_pw_len,
- int string_flags)
+bool decode_pw_buffer(TALLOC_CTX *ctx,
+ uint8 in_buffer[516],
+ char **pp_new_pwrd,
+ uint32 *new_pw_len,
+ int string_flags)
{
int byte_len=0;
+ *pp_new_pwrd = NULL;
+ *new_pw_len = 0;
+
/* the incoming buffer can be any alignment. */
string_flags |= STR_NOALIGN;
@@ -550,22 +555,31 @@ bool decode_pw_buffer(uint8 in_buffer[516], char *new_pwrd,
if ( (byte_len < 0) || (byte_len > 512)) {
DEBUG(0, ("decode_pw_buffer: incorrect password length (%d).\n", byte_len));
DEBUG(0, ("decode_pw_buffer: check that 'encrypt passwords = yes'\n"));
- return False;
+ return false;
}
- /* decode into the return buffer. Buffer length supplied */
- *new_pw_len = pull_string(NULL, 0, new_pwrd,
- &in_buffer[512 - byte_len], new_pwrd_size,
- byte_len, string_flags);
+ /* decode into the return buffer. */
+ *new_pw_len = pull_string_talloc(ctx,
+ NULL,
+ 0,
+ pp_new_pwrd,
+ &in_buffer[512 - byte_len],
+ byte_len,
+ string_flags);
+
+ if (!*pp_new_pwrd || *new_pw_len == 0) {
+ DEBUG(0, ("decode_pw_buffer: pull_string_talloc failed\n"));
+ return false;
+ }
#ifdef DEBUG_PASSWORD
DEBUG(100,("decode_pw_buffer: new_pwrd: "));
- dump_data(100, (uint8 *)new_pwrd, *new_pw_len);
+ dump_data(100, (uint8 *)*pp_new_pwrd, *new_pw_len);
DEBUG(100,("multibyte len:%d\n", *new_pw_len));
DEBUG(100,("original char len:%d\n", byte_len/2));
#endif
-
- return True;
+
+ return true;
}
/***********************************************************