git.samba.org
/
ira
/
wip.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5dcf006
)
lib-util: check for too many combinations in generate_unique_strs()
author
Andrew Tridgell
<tridge@samba.org>
Tue, 20 Oct 2009 00:34:49 +0000
(11:34 +1100)
committer
Andrew Tridgell
<tridge@samba.org>
Tue, 20 Oct 2009 00:34:49 +0000
(11:34 +1100)
lib/util/genrand.c
patch
|
blob
|
history
diff --git
a/lib/util/genrand.c
b/lib/util/genrand.c
index 6002c0647eac4d4bba462cd7e53d1f2913a5abbe..f0544023f14d29c7c8104d825a246e2cd9a9d48b 100644
(file)
--- 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;