summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-10-20 11:34:49 +1100
committerAndrew Tridgell <tridge@samba.org>2009-10-20 11:34:49 +1100
commitf49818e422b550b5080601e640e6ee5d49c80a81 (patch)
tree5580f452dea765b86144a884bb1c7a4666a6f622 /lib
parent5dcf0069b68149575fe6166019dd90b73885926b (diff)
downloadsamba-f49818e422b550b5080601e640e6ee5d49c80a81.tar.gz
samba-f49818e422b550b5080601e640e6ee5d49c80a81.tar.bz2
samba-f49818e422b550b5080601e640e6ee5d49c80a81.zip
lib-util: check for too many combinations in generate_unique_strs()
Diffstat (limited to 'lib')
-rw-r--r--lib/util/genrand.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/util/genrand.c b/lib/util/genrand.c
index 6002c0647e..f0544023f1 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;