Skip to content

Commit ce3cf00

Browse files
committed
Fixed byte conversion issue during logging under zlinux
1 parent 6d9327f commit ce3cf00

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

CHANGES

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* Added a better random bytes generator using apr_generate_random_bytes() to create
1616
the HMAC key.
1717

18+
* Fixed byte conversion issue during logging under Linux s390x platform.
19+
1820
* Fixed compilation bug with LibXML2 2.9.0 (Thanks Athmane Madjoudj).
1921

2022
* Fixed parsing error with modsecurity-recommended.conf and Apache 2.4.

apache2/msc_logging.c

+4
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,11 @@ static char *construct_auditlog_filename(apr_pool_t *mp, const char *uniqueid) {
229229
* as an audit log boundary.
230230
*/
231231
static char *create_auditlog_boundary(request_rec *r) {
232+
#ifdef LINUX_S390
233+
int data = swap_int32(rand());
234+
#else
232235
unsigned long data = rand();
236+
#endif
233237
/* Do note that I tried using apr_generate_random_bytes but it turned
234238
* out to be terribly slow for some reason. Needs further investigation.
235239
*/

apache2/msc_util.c

+9
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ static unsigned char *c2x(unsigned what, unsigned char *where);
7474
static unsigned char x2c(unsigned char *what);
7575
static unsigned char xsingle2c(unsigned char *what);
7676

77+
#ifdef LINUX_S390
78+
int swap_int32(int x) {
79+
int swap = ((x>>24)&0xff) | ((x<<8)&0xff0000) |
80+
((x>>8)&0xff00) | ((x<<24)&0xff000000);
81+
return swap;
82+
}
83+
#endif
84+
85+
7786
/** \brief Decode utf-8 to unicode format.
7887
*
7988
* \param mp Pointer to memory pool

apache2/msc_util.h

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ int DSOLOCAL inet_pton(int family, const char *src, void *dst);
4646
#define UNICODE_ERROR_RESTRICTED_CHARACTER -4
4747
#define UNICODE_ERROR_DECODING_ERROR -5
4848

49+
#ifdef LINUX_S390
50+
int DSOLOCAL swap_int32(int x);
51+
#endif
52+
53+
4954
char DSOLOCAL *utf8_unicode_inplace_ex(apr_pool_t *mp, unsigned char *input, long int input_len, int *changed);
5055

5156
char DSOLOCAL *m_strcasestr(const char *haystack, const char *needle);

configure.ac

+7-1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ case $host in
100100
*-*-linux*)
101101
echo "Checking plataform... Identified as Linux"
102102
linuxos=true
103+
case "${host_cpu}" in
104+
s390x)
105+
cpu_type="-DLINUX_S390"
106+
;;
107+
esac
103108
;;
104109
*-*-solaris*)
105110
echo "Checking plataform... Identified as Solaris"
@@ -135,6 +140,7 @@ AM_CONDITIONAL([AIX], [test x$aixos = xtrue])
135140
AM_CONDITIONAL([HPUX], [test x$hpuxos = xtrue])
136141
AM_CONDITIONAL([MACOSX], [test x$macos = xtrue])
137142
AM_CONDITIONAL([LINUX], [test x$linuxos = xtrue])
143+
AM_CONDITIONAL([LINUX390], [test x$linuxos390 = xtrue])
138144
AM_CONDITIONAL([SOLARIS], [test x$solarisos = xtrue])
139145
AM_CONDITIONAL([FREEBSD], [test x$freebsdos = xtrue])
140146
AM_CONDITIONAL([OPENBSD], [test x$openbsdos = xtrue])
@@ -627,7 +633,7 @@ else
627633
fi
628634
fi
629635

630-
MODSEC_EXTRA_CFLAGS="$pcre_study $pcre_match_limit $pcre_match_limit_recursion $pcre_jit $request_early $lua_cache $debug_conf $debug_cache $debug_acmp $debug_mem $perf_meas $modsec_api"
636+
MODSEC_EXTRA_CFLAGS="$pcre_study $pcre_match_limit $pcre_match_limit_recursion $pcre_jit $request_early $lua_cache $debug_conf $debug_cache $debug_acmp $debug_mem $perf_meas $modsec_api $cpu_type"
631637

632638
APXS_WRAPPER=build/apxs-wrapper
633639
APXS_EXTRA_CFLAGS=""

0 commit comments

Comments
 (0)