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.
This commit is contained in:
Mike Gelfand 2016-10-18 00:05:03 +03:00
parent f9c0ce63b8
commit eda26f7590
3 changed files with 4 additions and 4 deletions

View File

@ -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';

View File

@ -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)

View File

@ -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)