about summary refs log tree commit diff stats
path: root/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/common.c b/src/common.c
index eca444e6..6020b8c3 100644
--- a/src/common.c
+++ b/src/common.c
@@ -441,13 +441,14 @@ get_random_string(int length)
     GRand* prng;
     char* rand;
     char alphabet[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+    int endrange = sizeof(alphabet) - 1;
 
     rand = calloc(length + 1, sizeof(char));
 
     prng = g_rand_new();
 
     for (int i = 0; i < length; i++) {
-        rand[i] = alphabet[g_rand_int_range(prng, 0, sizeof(alphabet))];
+        rand[i] = alphabet[g_rand_int_range(prng, 0, endrange)];
     }
     g_rand_free(prng);