Projects
Extra
ncrack
ncrack-fix-compile-errors.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ncrack-fix-compile-errors.patch of Package ncrack (Revision 3)
Currently displaying revision
3
,
Show latest
--- Makefile.in | 1 - modules/ncrack_psql.cc | 4 ++-- modules/ncrack_webform.cc | 2 +- modules/ncrack_winrm.cc | 29 +++++++++++++++-------------- nbase/Makefile.in | 2 -- ncrack_resume.cc | 2 +- nsock/src/Makefile.in | 2 -- opensshlib/configure | 2 +- opensshlib/configure.ac | 46 +++++++++++++++++++++++++++++++++++++++------- opensshlib/xmalloc.c | 1 + 10 files changed, 60 insertions(+), 31 deletions(-) --- a/Makefile.in +++ b/Makefile.in @@ -18,7 +18,6 @@ export OPENSSHLIB_DIR = @OPENSSHLIB_DIR@ DEFS = @DEFS@ -DNCRACK_NAME=\"$(NCRACK_NAME)\" -DNCRACK_URL=\"$(NCRACK_URL)\" \ -DNCRACK_PLATFORM=\"$(NCRACK_PLATFORM)\" -DNCRACKDATADIR=\"$(ncrackdatadir)\" -DEFS += -D_FORTIFY_SOURCE=2 CC = @CC@ CXX = @CXX@ --- a/modules/ncrack_psql.cc +++ b/modules/ncrack_psql.cc @@ -165,7 +165,7 @@ static char *enhex(char *dest, const uns /* Arguments are assumed to be non-NULL, with the exception of nc and cnonce, which may be garbage only if qop == QOP_NONE. */ -static void make_response(char buf[MD5_DIGEST_LENGTH * 2 + 3], +static void make_response(char buf[MD5_DIGEST_LENGTH * 2 + 3 + 1], const char *username, const char *password, const char *salt) { char HA1_hex[MD5_DIGEST_LENGTH * 2 + 1]; @@ -292,7 +292,7 @@ ncrack_psql(nsock_pool nsp, Connection * memset(psql_code, 0, sizeof(psql_code)); memset(psql_salt, 0, sizeof(psql_salt)); - char response_hex[MD5_DIGEST_LENGTH *2 + 3]; + char response_hex[MD5_DIGEST_LENGTH *2 + 3 + 1]; switch (con->state) { case PSQL_INIT: --- a/modules/ncrack_webform.cc +++ b/modules/ncrack_webform.cc @@ -213,7 +213,7 @@ ncrack_webform(nsock_pool nsp, Connectio /* Now append the form to the ougoing buffer */ con->outbuf->append("{\"email\":\"", 10); con->outbuf->append(con->user, strlen(con->user)); - con->outbuf->append("\"\,\"password\":\"", 14); + con->outbuf->append("\",\"password\":\"", 14); con->outbuf->append(con->pass, strlen(con->pass)); con->outbuf->append("\"}", 2); --- a/modules/ncrack_winrm.cc +++ b/modules/ncrack_winrm.cc @@ -191,7 +191,7 @@ static void winrm_negotiate(nsock_pool n static int winrm_loop_read(nsock_pool nsp, Connection *con); static void winrm_free(Connection *con); -static void rand_str(char *dest, size_t length); +static void rand_mem(char *dest, size_t length); static void extend_key_56_to_64(const unsigned char *key_56, char *key); static void setup_des_key(const unsigned char *key_56, DES_key_schedule *ks); static uint64_t unix2nttime(time_t unix_time); @@ -281,9 +281,10 @@ ncrack_winrm(nsock_pool nsp, Connection /* Send 5 random characters. The number of characters * sent in this message is irrelevant. An empty request body is also valid. */ - tmplen = 5 + 1; + tmplen = 5; tmp = (char *)safe_malloc(tmplen + 1); - rand_str(tmp, 5); + rand_mem(tmp, 5); + tmp[tmplen] = '\0'; con->outbuf->append(tmp, strlen(tmp)); free(tmp); @@ -471,7 +472,7 @@ winrm_negotiate(nsock_pool nsp, Connecti char *b64; char *start, *end; char *challenge; - char *type2; + char *type2, *type2_p; char *target_info; size_t i; size_t domainlen; @@ -627,17 +628,16 @@ winrm_negotiate(nsock_pool nsp, Connecti } challenge = Strndup(start, i); tmp = strtok (challenge,"\r\n"); - type2 = (char *)safe_malloc((strlen(tmp) + 1)); + tmplen = strlen(tmp); + type2_p = type2 = (char *)safe_malloc(tmplen + 1); /* Base64 decode the type2 message (challenge) */ - tmplen = strlen(tmp); - base64_decode(tmp, tmplen, type2); - - if (!type2) { + i = base64_decode(tmp, tmplen, type2); + if (!i) { /* Type2 message decoding failed. */ - free(type2); + free(type2_p); serv->end.orly = true; tmpsize = sizeof("Invalid type2 message.\n"); serv->end.reason = (char *)safe_malloc(tmpsize); @@ -646,6 +646,7 @@ winrm_negotiate(nsock_pool nsp, Connecti return ncrack_module_end(nsp, con); } + /* NTLM type-2 message structure: * Index Description Content * 0 NTLMSSP Signature Null-terminated ASCII "NTLMSSP" @@ -694,7 +695,7 @@ winrm_negotiate(nsock_pool nsp, Connecti /* In this case, the type2 message flag is not present. * Exit gracefully. */ - free(type2); + free(type2_p); serv->end.orly = true; tmpsize = sizeof("Invalid type2 message.\n"); serv->end.reason = (char *)safe_malloc(tmpsize); @@ -765,6 +766,7 @@ winrm_negotiate(nsock_pool nsp, Connecti for (i = 0; i < 3; i++) { type2++; } + free(type2_p); targetinfo_offset = (int) tmp_buf[0]; @@ -998,7 +1000,7 @@ winrm_negotiate(nsock_pool nsp, Connecti /* Generate 8 random characters for NTLMv2 and LMv2 * hashes. */ - rand_str(entropy, 8); + rand_mem(entropy, 8); /* Calculate NTLM hash as we did before for v1. * After calculating the NTLM hash we concatenate @@ -1369,7 +1371,7 @@ winrm_free(Connection *con) static void -rand_str(char *dest, size_t length) +rand_mem(char *dest, size_t length) { char charset[] = "0123456789" "abcdefghijklmnopqrstuvwxyz" @@ -1379,7 +1381,6 @@ rand_str(char *dest, size_t length) size_t index = (double) rand() / RAND_MAX * (sizeof charset - 1); *dest++ = charset[index]; } - *dest = '\0'; } /* --- a/nbase/Makefile.in +++ b/nbase/Makefile.in @@ -11,8 +11,6 @@ AR = ar RANLIB = @RANLIB@ CCOPT = DEFS = @DEFS@ -# With GCC, add extra security checks to source code. -DEFS += -D_FORTIFY_SOURCE=2 CPPFLAGS = @CPPFLAGS@ CFLAGS = @CFLAGS@ $(CCOPT) $(GLIB_CFLAGS) $(DEFS) $(INCLS) STATIC = --- a/ncrack_resume.cc +++ b/ncrack_resume.cc @@ -478,7 +478,7 @@ ncrack_resume(char *fname, int *myargc, if (!q || ((unsigned int) (q - p) >= sizeof(ncrack_arg_buffer) - 32)) fatal("Unable to parse supposed restore file %s .", fname); - strncpy(ncrack_arg_buffer, "ncrack ", 7); + memcpy(ncrack_arg_buffer, "ncrack ", 7); if ((q-p) + 7 + 1 >= (int) sizeof(ncrack_arg_buffer)) fatal("0verfl0w"); memcpy(ncrack_arg_buffer + 7, p, q - p); --- a/nsock/src/Makefile.in +++ b/nsock/src/Makefile.in @@ -12,8 +12,6 @@ AR = ar RANLIB = @RANLIB@ CCOPT = DEFS = @DEFS@ -DNSOCK_VERSION=\"$(NSOCK_VERSION)\" -# With GCC, add extra security checks to source code. -DEFS += -D_FORTIFY_SOURCE=2 INCLS = -I../include CFLAGS = @CFLAGS@ $(CCOPT) # CFLAGS = -g -Wall $(DEFS) $(INCLS) --- a/opensshlib/configure +++ b/opensshlib/configure @@ -8922,7 +8922,7 @@ main () int a=0, b=0, c=0, d=0, n, v; n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d); - if (n != 3 && n != 4) + if (n != 2 && n != 3 && n != 4) exit(1); v = a*1000000 + b*10000 + c*100 + d; fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v); --- a/opensshlib/configure.ac +++ b/opensshlib/configure.ac @@ -200,7 +200,6 @@ if test "$GCC" = "yes" || test "$GCC" = OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign]) OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result]) OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing]) - OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2]) if test "x$use_toolchain_hardening" = "x1"; then OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro]) OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now]) @@ -1111,7 +1110,10 @@ mips-sony-bsd|mips-sony-newsos4) esac AC_MSG_CHECKING([compiler and flags for sanity]) -AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], [[ exit(0); ]])], +AC_RUN_IFELSE([AC_LANG_PROGRAM([[ +#include <stdio.h> +#include <stdlib.h> +]], [[ exit(0); ]])], [ AC_MSG_RESULT([yes]) ], [ AC_MSG_RESULT([no]) @@ -1234,7 +1236,7 @@ AC_RUN_IFELSE([AC_LANG_PROGRAM([[ [[ int a=0, b=0, c=0, d=0, n, v; n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d); - if (n != 3 && n != 4) + if (n != 2 && n != 3 && n != 4) exit(1); v = a*1000000 + b*10000 + c*100 + d; fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v); @@ -1349,6 +1351,7 @@ AC_MSG_CHECKING([whether struct dirent a AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ #include <sys/types.h> +#include <stdlib.h> #include <dirent.h>]], [[ struct dirent d; @@ -1849,6 +1852,9 @@ AC_CHECK_FUNCS([setresuid], [ AC_MSG_CHECKING([if setresuid seems to work]) AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif #include <stdlib.h> #include <errno.h> ]], [[ @@ -1874,6 +1880,9 @@ AC_CHECK_FUNCS([setresgid], [ [AC_LANG_PROGRAM([[ #include <stdlib.h> #include <errno.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif ]], [[ errno=0; setresgid(0,0,0); @@ -1944,7 +1953,10 @@ AC_CHECK_FUNC([getpagesize], if test "x$ac_cv_func_snprintf" = "xyes" ; then AC_MSG_CHECKING([whether snprintf correctly terminates long strings]) AC_RUN_IFELSE( - [AC_LANG_PROGRAM([[ #include <stdio.h> ]], + [AC_LANG_PROGRAM([[ +#include <stdio.h> +#include <stdlib.h> +]], [[ char b[5]; snprintf(b,5,"123456789"); @@ -2035,6 +2047,9 @@ if test "x$ac_cv_func_mkdtemp" = "xyes" AC_MSG_CHECKING([for (overly) strict mkstemp]) AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif #include <stdlib.h> ]], [[ char template[]="conftest.mkstemp-test"; @@ -2063,6 +2078,13 @@ if test ! -z "$check_for_openpty_ctty_bu AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ #include <stdio.h> +#include <stdlib.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_PTY_H +#include <pty.h> +#endif #include <sys/fcntl.h> #include <sys/types.h> #include <sys/wait.h> @@ -2346,6 +2368,7 @@ if test "x$openssl" = "xyes" ; then AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ #include <stdio.h> + #include <stdlib.h> #include <string.h> #include <openssl/opensslv.h> #define DATA "conftest.sslincver" @@ -2380,6 +2403,7 @@ if test "x$openssl" = "xyes" ; then AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ #include <stdio.h> + #include <stdlib.h> #include <string.h> #define OPENSSL_API_COMPAT 0x10000000L #include <openssl/opensslv.h> @@ -3186,6 +3210,7 @@ if test -z "$have_llong_max"; then AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ #include <stdio.h> +#include <stdlib.h> /* Why is this so damn hard? */ #ifdef __GNUC__ # undef __GNUC__ @@ -3644,6 +3669,7 @@ dnl test snprintf (broken on SCO w/gcc) AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include <stdio.h> +#include <stdlib.h> #include <string.h> #ifdef HAVE_SNPRINTF main() @@ -3701,6 +3727,7 @@ AC_CHECK_MEMBER([struct __res_state.retr [Define if we don't have struct __res_state in resolv.h])], [[ #include <stdio.h> +#include <stdlib.h> #if HAVE_SYS_TYPES_H # include <sys/types.h> #endif @@ -3744,6 +3771,7 @@ AC_CACHE_CHECK([for msg_accrights field #include <sys/types.h> #include <sys/socket.h> #include <sys/uio.h> +#include <stdlib.h> ]], [[ #ifdef msg_accrights #error "msg_accrights is a macro" @@ -3804,6 +3832,7 @@ AC_CACHE_CHECK([for msg_control field in AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> #include <sys/socket.h> +#include <stdlib.h> #include <sys/uio.h> ]], [[ #ifdef msg_control @@ -3825,7 +3854,7 @@ if test "x$ac_cv_have_control_in_msghdr" fi AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ extern char *__progname; printf("%s", __progname); ]])], [ ac_cv_libc_defines___progname="yes" ], [ ac_cv_libc_defines___progname="no" @@ -3897,7 +3926,7 @@ if test "x$ac_cv_have_getopt_optreset" = fi AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])], [ ac_cv_libc_defines_sys_errlist="yes" ], [ ac_cv_libc_defines_sys_errlist="no" @@ -3910,7 +3939,7 @@ fi AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[ extern int sys_nerr; printf("%i", sys_nerr);]])], [ ac_cv_libc_defines_sys_nerr="yes" ], [ ac_cv_libc_defines_sys_nerr="no" @@ -4220,6 +4249,7 @@ AC_ARG_WITH([maildir], AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ #include <stdio.h> +#include <stdlib.h> #include <string.h> #ifdef HAVE_PATHS_H #include <paths.h> @@ -4366,6 +4396,7 @@ if test -z "$disable_shadow" ; then AC_MSG_CHECKING([if the systems has expire shadow information]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> +#include <stdlib.h> #include <shadow.h> struct spwd sp; ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])], @@ -4464,6 +4495,7 @@ otherwise scp will not work.]) [AC_LANG_PROGRAM([[ /* find out what STDPATH is */ #include <stdio.h> +#include <stdlib.h> #ifdef HAVE_PATHS_H # include <paths.h> #endif --- a/opensshlib/xmalloc.c +++ b/opensshlib/xmalloc.c @@ -13,6 +13,7 @@ * called by a name other than "ssh" or "Secure Shell". */ +#define _GNU_SOURCE #include "includes.h" #include <stdarg.h>
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.