configure CC support, strrchr over rindex

This commit is contained in:
van Hauser 2017-01-31 11:03:00 +01:00
commit 9c3feee9b6
5 changed files with 27 additions and 18 deletions

View file

@ -1,6 +1,11 @@
Changelog for hydra Changelog for hydra
------------------- -------------------
Release 8.5-dev
* ./configure now honors the CC enviroment variable if present
* Favor strrchr() over rindex()
Release 8.4 Release 8.4
! Reports came in that the rdp module is not working reliable sometimes, most likely against new Windows versions. please test, report and if possible send a fix ! Reports came in that the rdp module is not working reliable sometimes, most likely against new Windows versions. please test, report and if possible send a fix
* Proxy support re-implemented: * Proxy support re-implemented:

26
configure vendored
View file

@ -15,9 +15,13 @@ if [ "$1" = "-h" -o "$1" = "--help" ]; then
echo " --nostrip do not per default strip binaries before install" echo " --nostrip do not per default strip binaries before install"
echo " --debug show debug output to trace errors" echo " --debug show debug output to trace errors"
echo " --help this here" echo " --help this here"
echo
echo If the CC environment variable is set, this is used as the compiler for the configure tests. The default is \"gcc\" otherwise.
exit 0 exit 0
fi fi
test -z "$CC" && CC=gcc
FHS="" FHS=""
SIXFOUR="" SIXFOUR=""
DEBUG="" DEBUG=""
@ -966,37 +970,37 @@ fi
echo "Checking for Android specialities ..." echo "Checking for Android specialities ..."
TMPC=comptest$$ TMPC=comptest$$
RINDEX=" not" STRRCHR=" not"
echo '#include <stdio.h>' > $TMPC.c echo '#include <stdio.h>' > $TMPC.c
echo '#include <strings.h>' >> $TMPC.c echo '#include <strings.h>' >> $TMPC.c
echo "int main() { char *x = rindex(\"test\", 'e'); if (x == NULL) return 0; else return 1; }" >> $TMPC.c echo "int main() { char *x = strrchr(\"test\", 'e'); if (x == NULL) return 0; else return 1; }" >> $TMPC.c
gcc -o $TMPC $TMPC.c > /dev/null 2>&1 $CC -o $TMPC $TMPC.c > /dev/null 2>&1
test -x $TMPC && RINDEX="" test -x $TMPC && STRRCHR=""
rm -f $TMPC $TMPC.c rm -f $TMPC $TMPC.c
echo " ... rindex()$RINDEX found" echo " ... strrchr()$STRRCHR found"
if [ -n "$CRYPTO_PATH" ]; then if [ -n "$CRYPTO_PATH" ]; then
RSA=" not" RSA=" not"
echo '#include <stdio.h>' > $TMPC.c echo '#include <stdio.h>' > $TMPC.c
echo '#include <openssl/rsa.h>' >> $TMPC.c echo '#include <openssl/rsa.h>' >> $TMPC.c
echo "int main() { RSA *rsa = RSA_generate_key(1024, RSA_F4, NULL, NULL); if (rsa == NULL) return 0; else return 1; }" >> $TMPC.c echo "int main() { RSA *rsa = RSA_generate_key(1024, RSA_F4, NULL, NULL); if (rsa == NULL) return 0; else return 1; }" >> $TMPC.c
#echo "int main() { RSA *rsa; RSA_generate_key_ex(rsa, 1024, 0, NULL); if (rsa == NULL) return 0; else return 1; }" >> $TMPC.c #echo "int main() { RSA *rsa; RSA_generate_key_ex(rsa, 1024, 0, NULL); if (rsa == NULL) return 0; else return 1; }" >> $TMPC.c
gcc -o $TMPC $TMPC.c -lssl -lcrypto > /dev/null 2>&1 $CC -o $TMPC $TMPC.c -lssl -lcrypto > /dev/null 2>&1
test -x $TMPC && RSA="" test -x $TMPC && RSA=""
rm -f $TMPC $TMPC.c rm -f $TMPC $TMPC.c
echo " ... RSA_generate_key()$RSA found" echo " ... RSA_generate_key()$RSA found"
fi fi
echo "Checking for secure compile option support in gcc ..." echo "Checking for secure compile option support in $CC ..."
GCCSEC="no" GCCSEC="no"
LDSEC="no" LDSEC="no"
GCCSECOPT="-fstack-protector-all --param ssp-buffer-size=4 -D_FORTIFY_SOURCE=2" GCCSECOPT="-fstack-protector-all --param ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"
echo '#include <stdio.h>' > $TMPC.c echo '#include <stdio.h>' > $TMPC.c
echo 'int main() { printf(""); return 0; }' >> $TMPC.c echo 'int main() { printf(""); return 0; }' >> $TMPC.c
gcc -pie -fPIE $GCCSEPOPT -o $TMPC $TMPC.c > /dev/null 2> $TMPC.c.err $CC -pie -fPIE $GCCSEPOPT -o $TMPC $TMPC.c > /dev/null 2> $TMPC.c.err
test -x $TMPC && GCCSEC="yes" test -x $TMPC && GCCSEC="yes"
grep -q fPI $TMPC.c.err || GCCSECOPT="-pie -fPIE $GCCSECOPT" grep -q fPI $TMPC.c.err || GCCSECOPT="-pie -fPIE $GCCSECOPT"
rm -f "$TMPC" rm -f "$TMPC"
gcc $GCCSECOPT -Wl,-z,now -Wl,-z,relro -o $TMPC $TMPC.c > /dev/null 2> $TMPC.c.err $CC $GCCSECOPT -Wl,-z,now -Wl,-z,relro -o $TMPC $TMPC.c > /dev/null 2> $TMPC.c.err
test -x $TMPC && { LDSEC="yes" ; GCCSECOPT="$GCCSECOPT -Wl,-z,now -Wl,-z,relro" ; } test -x $TMPC && { LDSEC="yes" ; GCCSECOPT="$GCCSECOPT -Wl,-z,now -Wl,-z,relro" ; }
rm -f $TMPC $TMPC.c $TMPC.c.err rm -f $TMPC $TMPC.c $TMPC.c.err
echo " Compiling... $GCCSEC" echo " Compiling... $GCCSEC"
@ -1060,8 +1064,8 @@ fi
if [ -n "$SSH_PATH" ]; then if [ -n "$SSH_PATH" ]; then
XDEFINES="$XDEFINES -DLIBSSH" XDEFINES="$XDEFINES -DLIBSSH"
fi fi
if [ -n "$RINDEX" ]; then if [ -n "$STRRCHR" ]; then
XDEFINES="$XDEFINES -DNO_RINDEX" XDEFINES="$XDEFINES -DNO_STRRCHR"
fi fi
if [ -n "$RSA" ]; then if [ -n "$RSA" ]; then
XDEFINES="$XDEFINES -DNO_RSA_LEGACY" XDEFINES="$XDEFINES -DNO_RSA_LEGACY"

View file

@ -32,10 +32,10 @@ char *nntp_read_server_capacity(int sock) {
buf[strlen(buf) - 1] = 0; buf[strlen(buf) - 1] = 0;
if (buf[strlen(buf) - 1] == '\r') if (buf[strlen(buf) - 1] == '\r')
buf[strlen(buf) - 1] = 0; buf[strlen(buf) - 1] = 0;
#ifdef NO_RINDEX #ifdef NO_STRRCHR
if ((ptr = strrchr(buf, '\n')) != NULL) {
#else
if ((ptr = rindex(buf, '\n')) != NULL) { if ((ptr = rindex(buf, '\n')) != NULL) {
#else
if ((ptr = strrchr(buf, '\n')) != NULL) {
#endif #endif
ptr++; ptr++;
if (isdigit((int) *ptr) && *(ptr + 3) == ' ') if (isdigit((int) *ptr) && *(ptr + 3) == ' ')

View file

@ -21,10 +21,10 @@ char *smtp_read_server_capacity(int sock) {
buf[strlen(buf) - 1] = 0; buf[strlen(buf) - 1] = 0;
if (buf[strlen(buf) - 1] == '\r') if (buf[strlen(buf) - 1] == '\r')
buf[strlen(buf) - 1] = 0; buf[strlen(buf) - 1] = 0;
#ifdef NO_RINDEX #ifdef NO_STRRCHR
if ((ptr = strrchr(buf, '\n')) != NULL) {
#else
if ((ptr = rindex(buf, '\n')) != NULL) { if ((ptr = rindex(buf, '\n')) != NULL) {
#else
if ((ptr = strrchr(buf, '\n')) != NULL) {
#endif #endif
ptr++; ptr++;
if (isdigit((int) *ptr) && *(ptr + 3) == ' ') if (isdigit((int) *ptr) && *(ptr + 3) == ' ')

View file

@ -171,7 +171,7 @@ char *SERVICES =
#define RESTOREFILE "./hydra.restore" #define RESTOREFILE "./hydra.restore"
#define PROGRAM "Hydra" #define PROGRAM "Hydra"
#define VERSION "v8.4" #define VERSION "v8.5-dev"
#define AUTHOR "van Hauser/THC" #define AUTHOR "van Hauser/THC"
#define EMAIL "<vh@thc.org>" #define EMAIL "<vh@thc.org>"
#define RESOURCE "http://www.thc.org/thc-hydra" #define RESOURCE "http://www.thc.org/thc-hydra"