summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-10-19 10:05:48 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-10-19 10:05:48 +0200
commit7275952568bbf003299d895b71b246f75851db93 (patch)
tree7ec15c35176685b8a486ae86055b6de36423ca2f /source3/lib
parentb1a1fbcbfb8f7d9b09bd26407ca4185b2cb4a0e3 (diff)
downloadsamba-7275952568bbf003299d895b71b246f75851db93.tar.gz
samba-7275952568bbf003299d895b71b246f75851db93.tar.bz2
samba-7275952568bbf003299d895b71b246f75851db93.zip
Add TALLOC_CTX pointer to generate_random_str(), for consistency with
Samba 4.
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/genrand.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/source3/lib/genrand.c b/source3/lib/genrand.c
index 57314c55df..d3abb3d77c 100644
--- a/source3/lib/genrand.c
+++ b/source3/lib/genrand.c
@@ -205,15 +205,11 @@ void generate_random_buffer( unsigned char *out, int len)
static char c_list[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_-#.,";
-char *generate_random_str(size_t len)
+char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len)
{
- static unsigned char retstr[256];
+ unsigned char *retstr = talloc_zero_array(mem_ctx, unsigned char, len);
size_t i;
- memset(retstr, '\0', sizeof(retstr));
-
- if (len > sizeof(retstr)-1)
- len = sizeof(retstr) -1;
generate_random_buffer( retstr, len);
for (i = 0; i < len; i++)
retstr[i] = c_list[ retstr[i] % (sizeof(c_list)-1) ];