tizenid: change rand() to rand_r( to fix the thread unsafe issue 43/78243/1
authortaeyoung <ty317.kim@samsung.com>
Tue, 5 Jul 2016 00:58:32 +0000 (09:58 +0900)
committertaeyoung <ty317.kim@samsung.com>
Tue, 5 Jul 2016 00:58:32 +0000 (09:58 +0900)
Change-Id: I172b39587d12bb066fbdda43ba6084f78a68a3cd
Signed-off-by: taeyoung <ty317.kim@samsung.com>
src/tizenid/tizenid.c

index 56fccd2..16382af 100755 (executable)
@@ -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);
        }