diff --git a/CHANGES b/CHANGES index b43c89c..6a6c48e 100644 --- a/CHANGES +++ b/CHANGES @@ -5,7 +5,9 @@ Release 8.5-dev * New command line option: -b : format option for -o output file (json only so far, happy for patches supporting others :) ) - thanks to veggiespam for the patch * ./configure now honors the CC enviroment variable if present +* fixed a bug in the NCP module * Favor strrchr() over rindex() +* Added refactoring patch by diadlo * Updated man page with missing command line options diff --git a/hydra-ncp.c b/hydra-ncp.c index f4bc62f..44c084c 100644 --- a/hydra-ncp.c +++ b/hydra-ncp.c @@ -64,8 +64,10 @@ int start_ncp(int s, char *ip, int port, unsigned char options, char *miscptr, F return 4; } memset(context, 0, sizeof(context)); - strncpy(context, login, strlen(login)); - strncpy(context + strlen(login), miscptr, sizeof(char) + 1); + strncpy(context, login, sizeof(context) - 2); + context[sizeof(context) - 2] = 0; + strncpy(context + strlen(login), miscptr, sizeof(context) - strlen(login) - 1); + context[sizeof(context) - 1] = 0; login = context; } } diff --git a/hydra.c b/hydra.c index 88ed522..a44511e 100644 --- a/hydra.c +++ b/hydra.c @@ -663,9 +663,7 @@ void module_usage() { #define STR_NULL(s) ((s) == NULL ? "(null)" : (s)) void hydra_debug(int force, char *string) { - int active = 0; - int inactive = 0; - int i; + int active = 0, inactive = 0, i; if (!debug && !force) return; @@ -700,9 +698,8 @@ void hydra_debug(int force, char *string) { STR_NULL(target->pass_ptr)); } - if (hydra_heads == NULL) { - return - } + if (hydra_heads == NULL) + return; for (i = 0; i < hydra_options.max_use; i++) { if (hydra_heads[i]->active >= 0) { @@ -4174,7 +4171,7 @@ int main(int argc, char *argv[]) { hydra_brains.sent, // tries (long unsigned int) ((elapsed_status - starttime) / 3600), // hours (long unsigned int) (((elapsed_status - starttime) % 3600) / 60), // minutes - (hydra_brains.todo_all + total_redo_count) - hydra_brains.sent, // left todo + (hydra_brains.todo_all + total_redo_count) - hydra_brains.sent != 0 ? (hydra_brains.todo_all + total_redo_count) - hydra_brains.sent : 1, // left todo (long unsigned int) (((double) (hydra_brains.todo_all + total_redo_count) - hydra_brains.sent) / ((double) hydra_brains.sent / (elapsed_status - starttime)) ) / 3600, // hours (((long unsigned int) (((double) (hydra_brains.todo_all + total_redo_count) - hydra_brains.sent) / ((double) hydra_brains.sent / (elapsed_status - starttime))