From a59b5e1a4f57ffe0d9fed7c646b345e39a898bbf Mon Sep 17 00:00:00 2001 From: Ben Fuhrmannek Date: Fri, 23 Sep 2016 17:49:05 +0200 Subject: whitespace --- crypt.c | 58 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/crypt.c b/crypt.c index e6867e1..7dd83f0 100644 --- a/crypt.c +++ b/crypt.c @@ -38,7 +38,7 @@ static void suhosin_get_ipv4(char *buf TSRMLS_DC) memset(buf, 0, 4); return; } - + for (i=0; i<4; i++) { if (raddr[0] == 0) { buf[i] = 0; @@ -56,7 +56,7 @@ char *suhosin_encrypt_string(char *str, int len, char *var, int vlen, char *key int padded_len, i, slen; unsigned char *crypted, *tmp; unsigned int check = 0x13579BDF; - + if (str == NULL) { return NULL; } @@ -83,10 +83,10 @@ char *suhosin_encrypt_string(char *str, int len, char *var, int vlen, char *key check += check << 1; check ^= (unsigned char)str[i]; } - + /* store ip value */ suhosin_get_ipv4((char *)crypted+4 TSRMLS_CC); - + /* store check value */ crypted[8] = check & 0xff; crypted[9] = (check >> 8) & 0xff; @@ -98,7 +98,7 @@ char *suhosin_encrypt_string(char *str, int len, char *var, int vlen, char *key crypted[13] = (len >> 8) & 0xff; crypted[14] = (len >> 16) & 0xff; crypted[15] = (len >> 24) & 0xff; - + for (i=0, tmp=crypted; i 0) { int j; @@ -106,7 +106,7 @@ char *suhosin_encrypt_string(char *str, int len, char *var, int vlen, char *key } suhosin_aes_encrypt((char *)tmp TSRMLS_CC); } - + tmp = php_base64_encode(crypted, padded_len+16, NULL); efree(crypted); slen=strlen((char *)tmp); @@ -126,11 +126,11 @@ char *suhosin_decrypt_string(char *str, int padded_len, char *var, int vlen, cha unsigned char *decrypted, *tmp; unsigned int check = 0x13579BDF; char buf[4]; - + if (str == NULL) { return NULL; } - + if (padded_len == 0) { if (orig_len) { *orig_len = 0; @@ -146,7 +146,7 @@ char *suhosin_decrypt_string(char *str, int padded_len, char *var, int vlen, cha case '_': str[i]='+'; break; } } - + decrypted = php_base64_decode((unsigned char *)str, padded_len, &len); if (decrypted == NULL || len < 2*16 || (len % 16) != 0) { error_out: @@ -158,7 +158,7 @@ error_out: } return NULL; } - + for (i=len-16, tmp=decrypted+i; i>=0; i-=16, tmp-=16) { suhosin_aes_decrypt((char *)tmp TSRMLS_CC); if (i > 0) { @@ -166,7 +166,7 @@ error_out: for (j=0; j<16; j++) tmp[j] ^= tmp[j-16]; } } - + /* retrieve orig_len */ o_len = decrypted[15]; o_len <<= 8; @@ -175,7 +175,7 @@ error_out: o_len |= decrypted[13]; o_len <<= 8; o_len |= decrypted[12]; - + if (o_len < 0 || o_len > len-16) { goto error_out; } @@ -191,13 +191,13 @@ error_out: check += check << 1; check ^= decrypted[16+i]; } - + /* check value */ - invalid = (decrypted[8] != (check & 0xff)) || - (decrypted[9] != ((check >> 8) & 0xff)) || - (decrypted[10] != ((check >> 16) & 0xff)) || + invalid = (decrypted[8] != (check & 0xff)) || + (decrypted[9] != ((check >> 8) & 0xff)) || + (decrypted[10] != ((check >> 16) & 0xff)) || (decrypted[11] != ((check >> 24) & 0xff)); - + /* check IP */ if (check_ra > 0) { if (check_ra > 4) { @@ -208,19 +208,19 @@ error_out: goto error_out; } } - + if (invalid) { goto error_out; } - + if (orig_len) { *orig_len = o_len; } - + memmove(decrypted, decrypted+16, o_len); decrypted[o_len] = 0; - /* we do not realloc() here because 16 byte less - is simply not worth the overhead */ + /* we do not realloc() here because 16 byte less + is simply not worth the overhead */ return (char *)decrypted; } @@ -230,21 +230,21 @@ char *suhosin_generate_key(char *key, zend_bool ua, zend_bool dr, long raddr, ch char *_dr = NULL; char *_ra = NULL; suhosin_SHA256_CTX ctx; - + if (ua) { _ua = suhosin_getenv("HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT")-1 TSRMLS_CC); } - + if (dr) { _dr = suhosin_getenv("DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT")-1 TSRMLS_CC); } - + if (raddr > 0) { _ra = suhosin_getenv("REMOTE_ADDR", sizeof("REMOTE_ADDR")-1 TSRMLS_CC); } - + SDEBUG("(suhosin_generate_key) KEY: %s - UA: %s - DR: %s - RA: %s", key,_ua,_dr,_ra); - + suhosin_SHA256Init(&ctx); if (key == NULL || *key == 0) { suhosin_SHA256Update(&ctx, (unsigned char*)"D3F4UL7", strlen("D3F4UL7")); @@ -263,7 +263,7 @@ char *suhosin_generate_key(char *key, zend_bool ua, zend_bool dr, long raddr, ch } else { long dots = 0; char *tmp = _ra; - + while (*tmp) { if (*tmp == '.') { dots++; @@ -278,6 +278,6 @@ char *suhosin_generate_key(char *key, zend_bool ua, zend_bool dr, long raddr, ch } suhosin_SHA256Final((unsigned char *)cryptkey, &ctx); cryptkey[32] = 0; /* uhmm... not really a string */ - + return cryptkey; } -- cgit v1.3