Fix CString::RandomString() to not insert NULL bytes in its result

sizeof() also includes the trailing NULL byte and thus that character was
chosen sometimes, too.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1052 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-05-12 19:35:15 +00:00
parent 4e6c6fea4a
commit 5ddf977b16
+2 -1
View File
@@ -665,7 +665,8 @@ CString CString::RandomString(unsigned int uLength) {
const char chars[] = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789!?.,:;/*-+_()";
const size_t len = sizeof(chars) / sizeof(char);
// -1 because sizeof() includes the trailing '\0' byte
const size_t len = sizeof(chars) / sizeof(chars[0]) - 1;
size_t p;
CString sRet;