From bb734b2c90fff632c5f9dbfb7e6f0de8a7d2b538 Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Fri, 18 Aug 2017 21:34:57 +0200 Subject: [PATCH] cisco: use strstr only on non-null var (found by ccc-analyzer). --- hydra-cisco.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hydra-cisco.c b/hydra-cisco.c index 6a65f77..32d0e20 100644 --- a/hydra-cisco.c +++ b/hydra-cisco.c @@ -127,7 +127,7 @@ void service_cisco(char *ip, int32_t sp, unsigned char options, char *miscptr, F switch (run) { case 1: /* connect and service init function */ { - unsigned char *buf2; + unsigned char *buf2 = NULL; int32_t f = 0; if (sock >= 0) @@ -151,9 +151,10 @@ void service_cisco(char *ip, int32_t sp, unsigned char options, char *miscptr, F hydra_child_exit(1); } do { - if (f != 0) + if (f != 0) { free(buf2); - else + buf2 = NULL; + } else f = 1; if ((buf2 = (unsigned char *) hydra_receive_line(sock)) == NULL) { if (failc < retry) { @@ -169,7 +170,7 @@ void service_cisco(char *ip, int32_t sp, unsigned char options, char *miscptr, F } if (buf2 != NULL && hydra_strcasestr((char*)buf2, "ress ENTER") != NULL) hydra_send(sock, "\r\n", 2, 0); - } while (strstr((char *) buf2, "assw") == NULL); + } while (buf2 != NULL && strstr((char *) buf2, "assw") == NULL); free(buf2); if (next_run != 0) break;