aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/connect.c6
-rw-r--r--lib/md4.c3
-rw-r--r--lib/md5.c5
-rw-r--r--lib/smtp.c4
-rw-r--r--lib/ssh.c50
-rw-r--r--lib/warnless.c20
-rw-r--r--lib/warnless.h2
-rw-r--r--tests/libtest/testtrace.c4
8 files changed, 60 insertions, 34 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 0affca288..38f68b428 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -93,7 +93,7 @@ static bool verifyconnect(curl_socket_t sockfd, int *error);
static void
tcpkeepalive(struct SessionHandle *data,
- int sockfd)
+ curl_socket_t sockfd)
{
int optval = data->set.tcp_keepalive?1:0;
@@ -104,14 +104,14 @@ tcpkeepalive(struct SessionHandle *data,
}
else {
#ifdef TCP_KEEPIDLE
- optval = data->set.tcp_keepidle;
+ optval = curlx_sltosi(data->set.tcp_keepidle);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,
(void *)&optval, sizeof(optval)) < 0) {
infof(data, "Failed to set TCP_KEEPIDLE on fd %d\n", sockfd);
}
#endif
#ifdef TCP_KEEPINTVL
- optval = data->set.tcp_keepintvl;
+ optval = curlx_sltosi(data->set.tcp_keepintvl);
if(setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL,
(void *)&optval, sizeof(optval)) < 0) {
infof(data, "Failed to set TCP_KEEPINTVL on fd %d\n", sockfd);
diff --git a/lib/md4.c b/lib/md4.c
index 828ce6277..cf6c36023 100644
--- a/lib/md4.c
+++ b/lib/md4.c
@@ -27,6 +27,7 @@
#ifdef USE_NSS
#include "curl_md4.h"
+#include "warnless.h"
typedef unsigned int UINT4;
@@ -275,7 +276,7 @@ void Curl_md4it(unsigned char *output, const unsigned char *input, size_t len)
{
MD4_CTX ctx;
MD4Init(&ctx);
- MD4Update(&ctx, input, (unsigned int)len);
+ MD4Update(&ctx, input, curlx_uztoui(len));
MD4Final(output, &ctx);
}
#endif /* USE_NSS */
diff --git a/lib/md5.c b/lib/md5.c
index cf8e053e3..13cb9e294 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -26,6 +26,7 @@
#include "curl_md5.h"
#include "curl_hmac.h"
+#include "warnless.h"
#ifdef USE_GNUTLS_NETTLE
@@ -412,7 +413,7 @@ void Curl_md5it(unsigned char *outbuffer, /* 16 bytes */
{
MD5_CTX ctx;
MD5_Init(&ctx);
- MD5_Update(&ctx, input, (unsigned int)strlen((char *)input));
+ MD5_Update(&ctx, input, curlx_uztoui(strlen((char *)input)));
MD5_Final(outbuffer, &ctx);
}
diff --git a/lib/smtp.c b/lib/smtp.c
index 4c3c512a8..83edb42b8 100644
--- a/lib/smtp.c
+++ b/lib/smtp.c
@@ -757,7 +757,7 @@ static CURLcode smtp_state_authcram_resp(struct connectdata *conn,
/* Compute digest. */
ctxt = Curl_HMAC_init(Curl_HMAC_MD5,
(const unsigned char *) conn->passwd,
- (unsigned int)(strlen(conn->passwd)));
+ curlx_uztoui(strlen(conn->passwd)));
if(!ctxt) {
Curl_safefree(chlg);
@@ -765,7 +765,7 @@ static CURLcode smtp_state_authcram_resp(struct connectdata *conn,
}
if(chlglen > 0)
- Curl_HMAC_update(ctxt, chlg, (unsigned int)(chlglen));
+ Curl_HMAC_update(ctxt, chlg, curlx_uztoui(chlglen));
Curl_safefree(chlg);
diff --git a/lib/ssh.c b/lib/ssh.c
index c9e41cc59..d6252f2b5 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -225,7 +225,7 @@ kbd_callback(const char *name, int name_len, const char *instruction,
#endif /* CURL_LIBSSH2_DEBUG */
if(num_prompts == 1) {
responses[0].text = strdup(conn->passwd);
- responses[0].length = (unsigned int)strlen(conn->passwd);
+ responses[0].length = curlx_uztoui(strlen(conn->passwd));
}
(void)prompts;
(void)abstract;
@@ -734,7 +734,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
*/
sshc->authlist = libssh2_userauth_list(sshc->ssh_session,
conn->user,
- (unsigned int)strlen(conn->user));
+ curlx_uztoui(strlen(conn->user)));
if(!sshc->authlist) {
if((err = libssh2_session_last_errno(sshc->ssh_session)) ==
@@ -827,8 +827,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
*/
rc = libssh2_userauth_publickey_fromfile_ex(sshc->ssh_session,
conn->user,
- (unsigned int)
- strlen(conn->user),
+ curlx_uztoui(
+ strlen(conn->user)),
sshc->rsa_pub,
sshc->rsa, sshc->passphrase);
if(rc == LIBSSH2_ERROR_EAGAIN) {
@@ -866,9 +866,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
case SSH_AUTH_PASS:
rc = libssh2_userauth_password_ex(sshc->ssh_session, conn->user,
- (unsigned int)strlen(conn->user),
+ curlx_uztoui(strlen(conn->user)),
conn->passwd,
- (unsigned int)strlen(conn->passwd),
+ curlx_uztoui(strlen(conn->passwd)),
NULL);
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
@@ -911,8 +911,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
/* Authentication failed. Continue with keyboard-interactive now. */
rc = libssh2_userauth_keyboard_interactive_ex(sshc->ssh_session,
conn->user,
- (unsigned int)
- strlen(conn->user),
+ curlx_uztoui(
+ strlen(conn->user)),
&kbd_callback);
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
@@ -1271,7 +1271,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
* first. This takes an extra protocol round trip.
*/
rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2,
- (unsigned int)strlen(sshc->quote_path2),
+ curlx_uztoui(strlen(sshc->quote_path2)),
LIBSSH2_SFTP_STAT,
&sshc->quote_attrs);
if(rc == LIBSSH2_ERROR_EAGAIN) {
@@ -1350,7 +1350,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
case SSH_SFTP_QUOTE_SETSTAT:
rc = libssh2_sftp_stat_ex(sshc->sftp_session, sshc->quote_path2,
- (unsigned int)strlen(sshc->quote_path2),
+ curlx_uztoui(strlen(sshc->quote_path2)),
LIBSSH2_SFTP_SETSTAT,
&sshc->quote_attrs);
if(rc == LIBSSH2_ERROR_EAGAIN) {
@@ -1374,9 +1374,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
case SSH_SFTP_QUOTE_SYMLINK:
rc = libssh2_sftp_symlink_ex(sshc->sftp_session, sshc->quote_path1,
- (unsigned int)strlen(sshc->quote_path1),
+ curlx_uztoui(strlen(sshc->quote_path1)),
sshc->quote_path2,
- (unsigned int)strlen(sshc->quote_path2),
+ curlx_uztoui(strlen(sshc->quote_path2)),
LIBSSH2_SFTP_SYMLINK);
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
@@ -1399,7 +1399,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
case SSH_SFTP_QUOTE_MKDIR:
rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sshc->quote_path1,
- (unsigned int)strlen(sshc->quote_path1),
+ curlx_uztoui(strlen(sshc->quote_path1)),
data->set.new_directory_perms);
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
@@ -1419,9 +1419,9 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
case SSH_SFTP_QUOTE_RENAME:
rc = libssh2_sftp_rename_ex(sshc->sftp_session, sshc->quote_path1,
- (unsigned int)strlen(sshc->quote_path1),
+ curlx_uztoui(strlen(sshc->quote_path1)),
sshc->quote_path2,
- (unsigned int)strlen(sshc->quote_path2),
+ curlx_uztoui(strlen(sshc->quote_path2)),
LIBSSH2_SFTP_RENAME_OVERWRITE |
LIBSSH2_SFTP_RENAME_ATOMIC |
LIBSSH2_SFTP_RENAME_NATIVE);
@@ -1446,7 +1446,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
case SSH_SFTP_QUOTE_RMDIR:
rc = libssh2_sftp_rmdir_ex(sshc->sftp_session, sshc->quote_path1,
- (unsigned int)strlen(sshc->quote_path1));
+ curlx_uztoui(strlen(sshc->quote_path1)));
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
}
@@ -1465,7 +1465,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
case SSH_SFTP_QUOTE_UNLINK:
rc = libssh2_sftp_unlink_ex(sshc->sftp_session, sshc->quote_path1,
- (unsigned int)strlen(sshc->quote_path1));
+ curlx_uztoui(strlen(sshc->quote_path1)));
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
}
@@ -1509,7 +1509,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
LIBSSH2_SFTP_ATTRIBUTES attrs;
if(data->state.resume_from < 0) {
rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path,
- (unsigned int)strlen(sftp_scp->path),
+ curlx_uztoui(strlen(sftp_scp->path)),
LIBSSH2_SFTP_STAT, &attrs);
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
@@ -1540,7 +1540,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
sshc->sftp_handle =
libssh2_sftp_open_ex(sshc->sftp_session, sftp_scp->path,
- (unsigned int)strlen(sftp_scp->path),
+ curlx_uztoui(strlen(sftp_scp->path)),
flags, data->set.new_file_perms,
LIBSSH2_SFTP_OPENFILE);
@@ -1699,7 +1699,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
case SSH_SFTP_CREATE_DIRS_MKDIR:
/* 'mode' - parameter is preliminary - default to 0644 */
rc = libssh2_sftp_mkdir_ex(sshc->sftp_session, sftp_scp->path,
- (unsigned int)strlen(sftp_scp->path),
+ curlx_uztoui(strlen(sftp_scp->path)),
data->set.new_directory_perms);
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
@@ -1733,8 +1733,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
*/
sshc->sftp_handle = libssh2_sftp_open_ex(sshc->sftp_session,
sftp_scp->path,
- (unsigned int)
- strlen(sftp_scp->path),
+ curlx_uztoui(
+ strlen(sftp_scp->path)),
0, 0, LIBSSH2_SFTP_OPENDIR);
if(!sshc->sftp_handle) {
if(libssh2_session_last_errno(sshc->ssh_session) ==
@@ -1875,7 +1875,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
sshc->readdir_len =
libssh2_sftp_symlink_ex(sshc->sftp_session,
sshc->readdir_linkPath,
- (unsigned int) strlen(sshc->readdir_linkPath),
+ curlx_uztoui(strlen(sshc->readdir_linkPath)),
sshc->readdir_filename,
PATH_MAX, LIBSSH2_SFTP_READLINK);
if(sshc->readdir_len == LIBSSH2_ERROR_EAGAIN) {
@@ -1961,7 +1961,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
*/
sshc->sftp_handle =
libssh2_sftp_open_ex(sshc->sftp_session, sftp_scp->path,
- (unsigned int)strlen(sftp_scp->path),
+ curlx_uztoui(strlen(sftp_scp->path)),
LIBSSH2_FXF_READ, data->set.new_file_perms,
LIBSSH2_SFTP_OPENFILE);
if(!sshc->sftp_handle) {
@@ -1988,7 +1988,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
LIBSSH2_SFTP_ATTRIBUTES attrs;
rc = libssh2_sftp_stat_ex(sshc->sftp_session, sftp_scp->path,
- (unsigned int)strlen(sftp_scp->path),
+ curlx_uztoui(strlen(sftp_scp->path)),
LIBSSH2_SFTP_STAT, &attrs);
if(rc == LIBSSH2_ERROR_EAGAIN) {
break;
diff --git a/lib/warnless.c b/lib/warnless.c
index 5fbc23400..6b77eea22 100644
--- a/lib/warnless.c
+++ b/lib/warnless.c
@@ -185,6 +185,7 @@ unsigned long curlx_uztoul(size_t uznum)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
+ DEBUGASSERT(uznum <= (size_t) CURL_MASK_ULONG);
return (unsigned long)(uznum & (size_t) CURL_MASK_ULONG);
#ifdef __INTEL_COMPILER
@@ -193,6 +194,25 @@ unsigned long curlx_uztoul(size_t uznum)
}
/*
+** unsigned size_t to unsigned int
+*/
+
+unsigned int curlx_uztoui(size_t uznum)
+{
+#ifdef __INTEL_COMPILER
+# pragma warning(push)
+# pragma warning(disable:810) /* conversion may lose significant bits */
+#endif
+
+ DEBUGASSERT(uznum <= (size_t) CURL_MASK_UINT);
+ return (unsigned int)(uznum & (size_t) CURL_MASK_UINT);
+
+#ifdef __INTEL_COMPILER
+# pragma warning(pop)
+#endif
+}
+
+/*
** signed long to signed int
*/
diff --git a/lib/warnless.h b/lib/warnless.h
index 9f14e7865..6040bee54 100644
--- a/lib/warnless.h
+++ b/lib/warnless.h
@@ -30,6 +30,8 @@ int curlx_uztosi(size_t uznum);
unsigned long curlx_uztoul(size_t uznum);
+unsigned int curlx_uztoui(size_t uznum);
+
int curlx_sltosi(long slnum);
unsigned int curlx_sltoui(long slnum);
diff --git a/tests/libtest/testtrace.c b/tests/libtest/testtrace.c
index 5cb5fec5e..b13c54e30 100644
--- a/tests/libtest/testtrace.c
+++ b/tests/libtest/testtrace.c
@@ -91,11 +91,13 @@ int libtest_debug_cb(CURL *handle, curl_infotype type,
struct timeval tv;
struct tm *now;
char timebuf[20];
+ char *timestr;
time_t secs;
(void)handle;
timebuf[0] = '\0';
+ timestr = &timebuf[0];
if(trace_cfg->tracetime) {
tv = tutil_tvnow();
@@ -111,7 +113,7 @@ int libtest_debug_cb(CURL *handle, curl_infotype type,
switch (type) {
case CURLINFO_TEXT:
- fprintf(stderr, "%s== Info: %s", &timebuf[0], data);
+ fprintf(stderr, "%s== Info: %s", timestr, data);
default: /* in case a new one is introduced to shock us */
return 0;