diff options
Diffstat (limited to 'source3/lib/genrand.c')
-rw-r--r-- | source3/lib/genrand.c | 8 |
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) ]; |