commit fc1fa9ffc7e3356458ec3 added a new function which needs to have a
stricter string formatting.  This was detected due to a compiler warning.

This patch makes sure that the %c parts in the string only gets 8 bits of data,
which seems to be the intension.  strlen() is used to determine the values 
passed
to the %c places in, but it was not taken into consideration that size_t which
strlen() returns might not be the same as int or char.

Signed-off-by: David Sommerseth <d...@users.sourceforge.net>
---
 socks.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/socks.c b/socks.c
index 58b3648..219accd 100644
--- a/socks.c
+++ b/socks.c
@@ -114,8 +114,8 @@ socks_username_password_auth (struct socks_proxy_info *p,
   creds.defined = 0;

   get_user_pass (&creds, p->authfile, UP_TYPE_SOCKS, GET_USER_PASS_MANAGEMENT);
-  snprintf (to_send, sizeof (to_send), "\x01%c%s%c%s", strlen(creds.username),
-            creds.username, strlen(creds.password), creds.password);
+  snprintf (to_send, sizeof (to_send), "\x01%c%s%c%s", (int) 
strlen(creds.username) & 0xff,
+            creds.username, (int) strlen(creds.password) & 0xff, 
creds.password);
   size = send (sd, to_send, strlen(to_send), MSG_NOSIGNAL);

   if (size != strlen (to_send))
-- 
1.7.2.3


Reply via email to