This repository was archived by the owner on Feb 28, 2024. It is now read-only.
File tree 2 files changed +41
-22
lines changed
2 files changed +41
-22
lines changed Original file line number Diff line number Diff line change 26
26
#include "config.h"
27
27
#endif
28
28
29
- #if defined(HAVE_OPENSSL_RAND_H ) && defined(HAVE_LIBCRYPTO )
30
- # include <openssl/rand.h>
31
- #elif defined(HAVE_GETRANDOM )
32
- # if defined(HAVE_LINUX_RANDOM_H )
33
- # include <linux/random.h>
34
- # elif defined(HAVE_SYS_RANDOM_H )
35
- # include <sys/random.h>
36
- # endif
37
- #else
38
- # include "magic.h"
39
- #endif
29
+ #include "magic.h"
40
30
41
31
/* Miscellaneous variables that are global, because we need
42
32
* store their values between different functions and connections.
@@ -88,16 +78,7 @@ HDR *_tac_req_header(u_char type, int cont_session) {
88
78
89
79
/* make session_id from pseudo-random number */
90
80
if (!cont_session ) {
91
- #if defined(HAVE_OPENSSL_RAND_H ) && defined(HAVE_LIBCRYPTO )
92
- // the preferred way is to use OpenSSL abstraction as we are linking it anyway for MD5
93
- RAND_pseudo_bytes ((unsigned char * ) & session_id , sizeof (session_id ));
94
- #elif defined(HAVE_GETRANDOM )
95
- // experimental
96
- getrandom ((void * ) & session_id , sizeof (session_id ), GRND_NONBLOCK );
97
- #else
98
- // if everything fails use the legacy code
99
81
session_id = magic ();
100
- #endif
101
82
}
102
83
th -> session_id = htonl (session_id );
103
84
Original file line number Diff line number Diff line change 30
30
#include "config.h"
31
31
#endif
32
32
33
+ #include "magic.h"
34
+
33
35
#ifdef _MSC_VER
34
36
# pragma section(".CRT$XCU",read)
35
37
# define INITIALIZER2_ (f ,p ) \
49
51
#endif
50
52
51
53
/* if OpenSSL library is available this legacy code will not be compiled in */
52
- #if !( defined(HAVE_OPENSSL_RAND_H ) && defined(HAVE_LIBCRYPTO ) )
54
+ #if defined(HAVE_OPENSSL_RAND_H ) && defined(HAVE_LIBCRYPTO )
53
55
54
- #include "magic.h"
56
+ #include <openssl/rand.h>
57
+
58
+ /*
59
+ * magic - Returns the next magic number.
60
+ */
61
+ u_int32_t
62
+ magic ()
63
+ {
64
+ u_int32_t num ;
65
+
66
+ RAND_pseudo_bytes ((unsigned char * )& num , sizeof (num ));
67
+
68
+ return num ;
69
+ }
70
+
71
+ #elif defined(HAVE_GETRANDOM )
72
+
73
+ # if defined(HAVE_LINUX_RANDOM_H )
74
+ # include <linux/random.h>
75
+ # elif defined(HAVE_SYS_RANDOM_H )
76
+ # include <sys/random.h>
77
+ # endif
78
+
79
+ /*
80
+ * magic - Returns the next magic number.
81
+ */
82
+ u_int32_t
83
+ magic ()
84
+ {
85
+ u_int32_t num ;
86
+
87
+ getrandom (& num , sizeof (num ), GRND_NONBLOCK );
88
+ return num ;
89
+ }
90
+
91
+ #else
55
92
56
93
/*
57
94
* magic_init - Initialize the magic number generator.
@@ -91,3 +128,4 @@ magic()
91
128
}
92
129
93
130
#endif
131
+
You can’t perform that action at this time.
0 commit comments