diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-10-20 11:34:49 +1100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2009-11-26 11:39:33 +0100 |
commit | b0095f92f59894c8ddc3313b3f3773372a18ef29 (patch) | |
tree | 1d1480845f63a1603997ceb5b5dc8d7f3641d106 /lib | |
parent | bdbd0f23cbd53ed0323c6aa80c33a7cdf0e6e4a0 (diff) | |
download | samba-b0095f92f59894c8ddc3313b3f3773372a18ef29.tar.gz |
lib-util: check for too many combinations in generate_unique_strs()
(cherry picked from commit e94c54ff3c83d0d19e0157216632bc99d5f8d0e3)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/genrand.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/util/genrand.c b/lib/util/genrand.c index 6002c0647ea..f0544023f14 100644 --- a/lib/util/genrand.c +++ b/lib/util/genrand.c @@ -375,7 +375,6 @@ _PUBLIC_ char** generate_unique_strs(TALLOC_CTX *mem_ctx, size_t len, const unsigned c_size = 42; int i, j; unsigned rem; - long long place; char ** strs = NULL; if (num == 0 || len == 0) @@ -397,6 +396,16 @@ _PUBLIC_ char** generate_unique_strs(TALLOC_CTX *mem_ctx, size_t len, } retstr[j] = 0; strs[i] = retstr; + if (rem != 0) { + /* we were not able to fit the number of + * combinations asked for in the length + * specified */ + DEBUG(0,(__location__ ": Too many combinations %u for length %u\n", + num, (unsigned)len)); + + talloc_free(strs); + return NULL; + } } return strs; |