From: taeyoung Date: Tue, 5 Jul 2016 00:58:32 +0000 (+0900) Subject: tizenid: change rand() to rand_r( to fix the thread unsafe issue X-Git-Tag: submit/tizen/20160705.090208~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=03ed3e23e958e25bff41bca4a418ea3ca20d0759;p=platform%2Fcore%2Fapi%2Fsystem-info.git tizenid: change rand() to rand_r( to fix the thread unsafe issue Change-Id: I172b39587d12bb066fbdda43ba6084f78a68a3cd Signed-off-by: taeyoung --- diff --git a/src/tizenid/tizenid.c b/src/tizenid/tizenid.c index 56fccd2..16382af 100755 --- a/src/tizenid/tizenid.c +++ b/src/tizenid/tizenid.c @@ -49,15 +49,16 @@ static int get_pw_key(char *pw, unsigned int len) { int i, val, poolsize; char *charpool = CHAR_POOL; + unsigned int seed; if (!pw) return -EINVAL; poolsize = strlen(charpool); - srand(time(NULL)); + seed = time(NULL); for (i = 0 ; i < len ; i++) { - val = rand() % poolsize; + val = rand_r(&seed) % poolsize; pw[i] = *(charpool + val); }