diff options
author | lurchi <lurchi@strangeplace.net> | 2019-06-27 10:49:40 +0200 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2019-06-27 10:49:40 +0200 |
commit | b9771c5f5edcbeb965fa291a281943d866c3ddb6 (patch) | |
tree | e53141e844dfe7032d018cb5bfebd31fe02f7816 /src/util/socks.c | |
parent | 0e7c93c3a0a3aa966503a8ae4caf3a21914e4126 (diff) | |
download | gnunet-b9771c5f5edcbeb965fa291a281943d866c3ddb6.tar.gz gnunet-b9771c5f5edcbeb965fa291a281943d866c3ddb6.zip |
use GNUNET_strlcpy instead of strncpy where possible
Diffstat (limited to 'src/util/socks.c')
-rw-r--r-- | src/util/socks.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/util/socks.c b/src/util/socks.c index 7eca04878..9e974e6bb 100644 --- a/src/util/socks.c +++ b/src/util/socks.c | |||
@@ -76,7 +76,7 @@ const char * SOCKS5_REP_names(int rep) | |||
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Encode a string for the SOCKS5 protocol by prefixing it a byte stating its | 78 | * Encode a string for the SOCKS5 protocol by prefixing it a byte stating its |
79 | * length and stipping the trailing zero byte. Truncates any string longer | 79 | * length and stripping the trailing zero byte. Truncates any string longer |
80 | * than 255 bytes. | 80 | * than 255 bytes. |
81 | * | 81 | * |
82 | * @param b buffer to contain the encoded string | 82 | * @param b buffer to contain the encoded string |
@@ -96,7 +96,10 @@ SOCK5_proto_string(unsigned char * b, | |||
96 | l=255; | 96 | l=255; |
97 | } | 97 | } |
98 | *(b++) = (unsigned char) l; | 98 | *(b++) = (unsigned char) l; |
99 | strncpy ((char *)b, s, l); | 99 | /* |
100 | * intentionally use strncpy (trailing zero byte must be stripped in b) | ||
101 | */ | ||
102 | strncpy ((char*)b, s, l); | ||
100 | return b+l; | 103 | return b+l; |
101 | } | 104 | } |
102 | 105 | ||
@@ -489,7 +492,7 @@ GNUNET_SOCKS_init_handshake_noauth () | |||
489 | */ | 492 | */ |
490 | void | 493 | void |
491 | GNUNET_SOCKS_set_handshake_destination (struct GNUNET_SOCKS_Handshake *ih, | 494 | GNUNET_SOCKS_set_handshake_destination (struct GNUNET_SOCKS_Handshake *ih, |
492 | const char *host, uint16_t port) | 495 | const char *host, uint16_t port) |
493 | { | 496 | { |
494 | union { | 497 | union { |
495 | struct in_addr in4; | 498 | struct in_addr in4; |