Commit b375472d authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

r14373@tombo: nickm | 2008-02-21 16:29:18 -0500

 Apply warnings about implicit 64-to-32 conversions; some from Sebastian Hahn; some not.


svn:r13664
parent 1cd90948
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ static int _crypto_global_initialized = 0;
static void
crypto_log_errors(int severity, const char *doing)
{
  unsigned int err;
  unsigned long err;
  const char *msg, *lib, *func;
  while ((err = ERR_get_error()) != 0) {
    msg = (const char*)ERR_reason_error_string(err);
@@ -518,10 +518,11 @@ crypto_pk_read_public_key_from_string(crypto_pk_env_t *env, const char *src,

  tor_assert(env);
  tor_assert(src);
  tor_assert(len<INT_MAX);

  b = BIO_new(BIO_s_mem()); /* Create a memory BIO */

  BIO_write(b, src, len);
  BIO_write(b, src, (int)len);

  if (env->key)
    RSA_free(env->key);
@@ -640,8 +641,9 @@ crypto_pk_public_encrypt(crypto_pk_env_t *env, char *to,
  tor_assert(env);
  tor_assert(from);
  tor_assert(to);
  tor_assert(fromlen<INT_MAX);

  r = RSA_public_encrypt(fromlen, (unsigned char*)from, (unsigned char*)to,
  r = RSA_public_encrypt((int)fromlen, (unsigned char*)from, (unsigned char*)to,
                         env->key, crypto_get_rsa_padding(padding));
  if (r<0) {
    crypto_log_errors(LOG_WARN, "performing RSA encryption");
@@ -665,11 +667,13 @@ crypto_pk_private_decrypt(crypto_pk_env_t *env, char *to,
  tor_assert(from);
  tor_assert(to);
  tor_assert(env->key);
  tor_assert(fromlen<INT_MAX);
  if (!env->key->p)
    /* Not a private key */
    return -1;

  r = RSA_private_decrypt(fromlen, (unsigned char*)from, (unsigned char*)to,
  r = RSA_private_decrypt((int)fromlen,
                          (unsigned char*)from, (unsigned char*)to,
                          env->key, crypto_get_rsa_padding(padding));

  if (r<0) {
@@ -693,7 +697,8 @@ crypto_pk_public_checksig(crypto_pk_env_t *env, char *to,
  tor_assert(env);
  tor_assert(from);
  tor_assert(to);
  r = RSA_public_decrypt(fromlen, (unsigned char*)from, (unsigned char*)to,
  tor_assert(fromlen < INT_MAX);
  r = RSA_public_decrypt((int)fromlen, (unsigned char*)from, (unsigned char*)to,
                         env->key, RSA_PKCS1_PADDING);

  if (r<0) {
@@ -754,11 +759,13 @@ crypto_pk_private_sign(crypto_pk_env_t *env, char *to,
  tor_assert(env);
  tor_assert(from);
  tor_assert(to);
  tor_assert(fromlen < INT_MAX);
  if (!env->key->p)
    /* Not a private key */
    return -1;

  r = RSA_private_encrypt(fromlen, (unsigned char*)from, (unsigned char*)to,
  r = RSA_private_encrypt((int)fromlen,
                          (unsigned char*)from, (unsigned char*)to,
                          env->key, RSA_PKCS1_PADDING);
  if (r<0) {
    crypto_log_errors(LOG_WARN, "generating RSA signature");
@@ -1672,8 +1679,8 @@ crypto_seed_rng(void)
  static const char *filenames[] = {
    "/dev/srandom", "/dev/urandom", "/dev/random", NULL
  };
  int fd;
  int i, n;
  int fd, i;
  size_t n;
#endif

#if USE_RAND_POLL
+1 −1
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ format_msg(char *buf, size_t buf_len,
    /* The message was too long; overwrite the end of the buffer with
     * "[...truncated]" */
    if (buf_len >= TRUNCATED_STR_LEN) {
      int offset = buf_len-TRUNCATED_STR_LEN;
      size_t offset = buf_len-TRUNCATED_STR_LEN;
      /* We have an extra 2 characters after buf_len to hold the \n\0,
       * so it's safe to add 1 to the size here. */
      strlcpy(buf+offset, TRUNCATED_STR, buf_len-offset+1);
+6 −5
Original line number Diff line number Diff line
@@ -331,8 +331,8 @@ round_to_power_of_2(uint64_t u64)
 * ===== */

/** Remove from the string <b>s</b> every character which appears in
 * <b>strip</b>.  Return the number of characters removed. */
int
 * <b>strip</b>. */
void
tor_strstrip(char *s, const char *strip)
{
  char *read = s;
@@ -344,7 +344,6 @@ tor_strstrip(char *s, const char *strip)
    }
  }
  *s = '\0';
  return read-s;
}

/** Return a pointer to a NUL-terminated hexadecimal string encoding
@@ -1000,7 +999,8 @@ tor_timegm(struct tm *tm)
    log_warn(LD_BUG, "Out-of-range argument to tor_timegm");
    return -1;
  }
  days = 365 * (year-1970) + n_leapdays(1970,year);
  tor_assert(year < INT_MAX);
  days = 365 * (year-1970) + n_leapdays(1970,(int)year);
  for (i = 0; i < tm->tm_mon; ++i)
    days += days_per_month[i];
  if (tm->tm_mon > 1 && IS_LEAPYEAR(year))
@@ -1328,6 +1328,7 @@ write_all(int fd, const char *buf, size_t count, int isSocket)
{
  size_t written = 0;
  int result;
  tor_assert(count < INT_MAX); /*XXXX021 make returnval an ssize_t */

  while (written != count) {
    if (isSocket)
@@ -1338,7 +1339,7 @@ write_all(int fd, const char *buf, size_t count, int isSocket)
      return -1;
    written += result;
  }
  return count;
  return (int)count;
}

/** Read from <b>fd</b> to <b>buf</b>, until we get <b>count</b> bytes
+1 −1
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ int strcasecmpstart(const char *s1, const char *s2)
int strcmpend(const char *s1, const char *s2) ATTR_PURE ATTR_NONNULL((1,2));
int strcasecmpend(const char *s1, const char *s2)
  ATTR_PURE ATTR_NONNULL((1,2));
int tor_strstrip(char *s, const char *strip) ATTR_NONNULL((1,2));
void tor_strstrip(char *s, const char *strip) ATTR_NONNULL((1,2));
long tor_parse_long(const char *s, int base, long min,
                    long max, int *ok, char **next);
unsigned long tor_parse_ulong(const char *s, int base, unsigned long min,