Skip to content

Commit

Permalink
Fix GCC warning with strncpy
Browse files Browse the repository at this point in the history
GCC 8.2.1 warns that: ‘strncpy’ specified bound depends on the length
of the source argument. The length of username and password is checked
beforehand anyways, so "strncpy(dst, src, strlen(src))" should be the
same as "strcpy(dst, src)".
  • Loading branch information
damag committed Oct 29, 2018
1 parent 345a616 commit f7f1753
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions socks5.c
Expand Up @@ -113,9 +113,9 @@ static int s5_client_auth(int s, const char *username, const char *password,
uint8_t plen = (uint8_t)strlen(password);
upauth[0] = RFC1929_VER; // VER = 1
upauth[1] = ulen; // ULEN
strncpy((char *)(upauth + 2), username, ulen); // UNAME
strcpy((char *)(upauth + 2), username); // UNAME
upauth[2 + ulen] = plen; // PLEN
strncpy((char *)(upauth + 3 + ulen), password, plen); // PASSWD
strcpy((char *)(upauth + 3 + ulen), password); // PASSWD
err = dill_bsend(s, (void *)upauth, 3 + ulen + plen, deadline);
if(dill_slow(err)) return -1;
uint8_t upauthr[2];
Expand Down

0 comments on commit f7f1753

Please sign in to comment.