mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Fix PRNG code
This commit is contained in:
parent
4ef3cc8eba
commit
575356f10c
@ -122,20 +122,20 @@ char *normalize_path(modsec_rec *msr, char *input) {
|
||||
* \retval seed random seed
|
||||
*/
|
||||
unsigned long prng() {
|
||||
short num_matrix1[10]; num_matrix2[10];
|
||||
short num_matrix1[10], num_matrix2[10];
|
||||
unsigned long num, num1, num2;
|
||||
short n, *p;
|
||||
unsigned short seed_num;
|
||||
unsigned long seed;
|
||||
|
||||
seed_num = seed & N16BITS_MASK;
|
||||
seed_num = seed & N16BITS_MAX;
|
||||
num = seed & N31BITS_MASK;
|
||||
|
||||
p = num_matrix1;
|
||||
|
||||
for(n = 18; n-- ; ) {
|
||||
num = 30903*seed_num + (num>>16);
|
||||
*p++ = seed_num = num & N16BITS_MASK;
|
||||
*p++ = seed_num = num & N16BITS_MAX;
|
||||
if (n == 9)
|
||||
p = num_matrix2;
|
||||
}
|
||||
@ -160,8 +160,8 @@ unsigned long prng() {
|
||||
|
||||
num_matrix1[0] = num1/N16BITS_MASK;
|
||||
num_matrix2[0] = num2/N16BITS_MASK;
|
||||
num_matrix1[1] = N16BITS_MASK&num1;
|
||||
num_matrix2[1] = N16BITS_MASK&num2;
|
||||
num_matrix1[1] = N16BITS_MAX & num1;
|
||||
num_matrix2[1] = N16BITS_MAX & num2;
|
||||
|
||||
seed = (((long)num_matrix1[1])<<16)+(long)num_matrix2[1];
|
||||
|
||||
|
@ -35,7 +35,7 @@ struct glinear {
|
||||
};
|
||||
|
||||
#define N16BITS_MASK 65536L
|
||||
#define N16BITS_MASK 0xFFFF
|
||||
#define N16BITS_MAX 0xFFFF
|
||||
#define N15BITS_MASK 0x7FFF
|
||||
#define N31BITS_MASK 0x7FFFFFFF
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user