From: ilho kim Date: Thu, 14 Sep 2023 06:58:52 +0000 (+0900) Subject: Revert "Replace the g_random_int() with the getrandom()" X-Git-Tag: accepted/tizen/unified/20230914.164948~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=07ec9470b73bdcffd6cc2e0c8d29ca1b143a0c17;hp=0a75e009a76afaa0bf671f1fdba62c67496ecc34;p=platform%2Fcore%2Fappfw%2Fapp2sd.git Revert "Replace the g_random_int() with the getrandom()" This reverts commit 49237995dcd62a496ee6753ed65977ac1bb1cabe. Because the current kernel doesn't support the getrandom Change-Id: Idcaed8e41887be15e46f0fbcbd36686b6331f2ec --- diff --git a/plugin/app2sd/server/app2sd_internals_utils.c b/plugin/app2sd/server/app2sd_internals_utils.c index 494db6d..678ace0 100644 --- a/plugin/app2sd/server/app2sd_internals_utils.c +++ b/plugin/app2sd/server/app2sd_internals_utils.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "app2sd_internals.h" @@ -355,14 +354,6 @@ char *_app2sd_generate_password(void) "!\"#$%&()*+,-./0123456789:;<=>?@ABCDE" \ "FGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; int i; - ssize_t s; - unsigned int rand_nums[PASSWD_LEN]; - - s = getrandom(rand_nums, sizeof(rand_nums), 0); - if (s < 0) { - _E("Failed to read random data errno : %d", errno); - return NULL; - } /* include null byte */ passwd = (char *)malloc(sizeof(char) * (PASSWD_LEN + 1)); @@ -372,7 +363,7 @@ char *_app2sd_generate_password(void) } for (i = 0; i < PASSWD_LEN; i++) - passwd[i] = charset[rand_nums[i] % ASCII_PASSWD_CHAR]; + passwd[i] = charset[g_random_int() % ASCII_PASSWD_CHAR]; passwd[i] = '\0'; return passwd;