mirror of
https://github.com/znc/znc.git
synced 2026-05-07 05:44:41 +02:00
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:
+2
-1
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user