Fix compilation warning

See below full log:

hydra-http-proxy.c: In function ‘start_http_proxy’:
hydra-http-proxy.c:26:26: warning: ‘%.200s’ directive writing up to 200 bytes into a region of size 24 [-Wformat-overflow=]
     sprintf(host, "Host: %.200s", ptr + 3);
                          ^~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from hydra.h:3,
                 from hydra-mod.h:4,
                 from hydra-http-proxy.c:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note: ‘__builtin___sprintf_chk’ output between 7 and 207 bytes into a destination of size 30
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       __bos (__s), __fmt, __va_arg_pack ());
       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
David Maciejak 2019-03-05 12:45:41 +08:00 committed by GitHub
parent e759b3768c
commit edc01ed049
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,7 @@ char *http_proxy_buf = NULL;
int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char options, char *miscptr, FILE * fp, char *hostname) {
char *empty = "";
char *login, *pass, buffer[500], buffer2[500];
char url[210], host[30];
char url[210], host[60];
char *header = ""; /* XXX TODO */
char *ptr, *fooptr;
@ -23,7 +23,7 @@ int32_t start_http_proxy(int32_t s, char *ip, int32_t port, unsigned char option
} else {
sprintf(url, "%.200s", miscptr);
ptr = strstr(miscptr, "://"); // :// check is in hydra.c
sprintf(host, "Host: %.200s", ptr + 3);
sprintf(host, "Host: %.50s", ptr + 3);
if ((ptr = index(host, '/')) != NULL)
*ptr = 0;
if ((ptr = index(host + 6, ':')) != NULL && host[0] != '[')