From eda26f7590412eaffa70be43f622779a704158c6 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Tue, 18 Oct 2016 00:05:03 +0300 Subject: [PATCH] Make sure `tr_sha1` calls pass lengths as int This fixes inability to authenticate with password-protected session, and a few more issues it seems. --- libtransmission/crypto-utils.c | 4 ++-- libtransmission/makemeta.c | 2 +- libtransmission/metainfo.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libtransmission/crypto-utils.c b/libtransmission/crypto-utils.c index a7268f5cb..82b44db97 100644 --- a/libtransmission/crypto-utils.c +++ b/libtransmission/crypto-utils.c @@ -141,7 +141,7 @@ tr_ssha1 (const char * plain_text) for (i = 0; i < saltval_len; ++i) salt[i] = salter[salt[i] % salter_len]; - tr_sha1 (sha, plain_text, strlen (plain_text), salt, (size_t) saltval_len, NULL); + tr_sha1 (sha, plain_text, (int) strlen (plain_text), salt, saltval_len, NULL); tr_sha1_to_hex (&buf[1], sha); memcpy (&buf[1 + 2 * SHA_DIGEST_LENGTH], &salt, saltval_len); buf[1 + 2 * SHA_DIGEST_LENGTH + saltval_len] = '\0'; @@ -170,7 +170,7 @@ tr_ssha1_matches (const char * ssha1, /* hash pass + salt */ my_ssha1 = tr_malloc (2 * SHA_DIGEST_LENGTH + saltlen + 2); - tr_sha1 (buf, plain_text, strlen (plain_text), salt, saltlen, NULL); + tr_sha1 (buf, plain_text, (int) strlen (plain_text), salt, (int) saltlen, NULL); tr_sha1_to_hex (&my_ssha1[1], buf); memcpy (my_ssha1 + 1 + 2 * SHA_DIGEST_LENGTH, salt, saltlen); my_ssha1[1 + 2 * SHA_DIGEST_LENGTH + saltlen] = '\0'; diff --git a/libtransmission/makemeta.c b/libtransmission/makemeta.c index fb1b675c9..589b12c52 100644 --- a/libtransmission/makemeta.c +++ b/libtransmission/makemeta.c @@ -293,7 +293,7 @@ getHashInfo (tr_metainfo_builder * b) assert (bufptr - buf == (int)thisPieceSize); assert (leftInPiece == 0); - tr_sha1 (walk, buf, thisPieceSize, NULL); + tr_sha1 (walk, buf, (int) thisPieceSize, NULL); walk += SHA_DIGEST_LENGTH; if (b->abortFlag) diff --git a/libtransmission/metainfo.c b/libtransmission/metainfo.c index 87feb7ce4..7b9caffdf 100644 --- a/libtransmission/metainfo.c +++ b/libtransmission/metainfo.c @@ -469,7 +469,7 @@ tr_metainfoParseImpl (const tr_session * session, { size_t len; char * bstr = tr_variantToStr (infoDict, TR_VARIANT_FMT_BENC, &len); - tr_sha1 (inf->hash, bstr, len, NULL); + tr_sha1 (inf->hash, bstr, (int) len, NULL); tr_sha1_to_hex (inf->hashString, inf->hash); if (infoDictLength != NULL)