mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
Merge branch 'matthiasc/for-main' into 'main'
printing: Avoid getrandom See merge request GNOME/gtk!5530
This commit is contained in:
commit
e51fa8b65b
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <sys/random.h>
|
|
||||||
|
|
||||||
#include "gtkprintbackendutils.h"
|
#include "gtkprintbackendutils.h"
|
||||||
|
|
||||||
@ -114,15 +113,13 @@ random_string (int n)
|
|||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"0123456789";
|
"0123456789";
|
||||||
|
|
||||||
char *str = g_new0 (char, n+1);
|
char *str = g_new0 (char, n + 1);
|
||||||
getrandom (str, n, 0);
|
for (int i = 0; i < n; i++)
|
||||||
for (int i=0; i<n; i++)
|
|
||||||
{
|
{
|
||||||
int rand = str[i] + 128;
|
int idx = g_random_int_range (0, strlen (charset));
|
||||||
int idx = rand % ((int) sizeof charset);
|
|
||||||
str[i] = charset[idx];
|
str[i] = charset[idx];
|
||||||
}
|
}
|
||||||
str[n] = '\0';
|
str[n] = '\0';
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user