[tor-commits] [tor/master] Fix warnings on 32-bit builds.

nickm at torproject.org nickm at torproject.org
Thu Sep 25 21:50:49 UTC 2014


commit 9190468246c75051a4dd11ec95342df50ea1dc75
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Sep 25 17:50:13 2014 -0400

    Fix warnings on 32-bit builds.
    
    When size_t is the most memory you can have, make sure that things
    referring to real parts of memory are size_t, not uint64_t or off_t.
    
    But not on any released Tor.
---
 src/common/crypto_curve25519.c        |    8 +++++---
 src/ext/ed25519/ref10/ed25519_ref10.h |    4 ++--
 src/ext/ed25519/ref10/open.c          |    2 +-
 src/ext/ed25519/ref10/sign.c          |    2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/common/crypto_curve25519.c b/src/common/crypto_curve25519.c
index 44b280a..dcb1e95 100644
--- a/src/common/crypto_curve25519.c
+++ b/src/common/crypto_curve25519.c
@@ -181,6 +181,7 @@ crypto_read_tagged_contents_from_file(const char *fname,
   char *content = NULL;
   struct stat st;
   ssize_t r = -1;
+  size_t st_size;
 
   *tag_out = NULL;
   st.st_size = 0;
@@ -189,6 +190,7 @@ crypto_read_tagged_contents_from_file(const char *fname,
     goto end;
   if (st.st_size < 32 || st.st_size > 32 + data_out_len)
     goto end;
+  st_size = (size_t)st.st_size;
 
   memcpy(prefix, content, 32);
   prefix[32] = 0;
@@ -205,12 +207,12 @@ crypto_read_tagged_contents_from_file(const char *fname,
   *tag_out = tor_strndup(prefix+5+strlen(typestring),
                          strlen(prefix)-8-strlen(typestring));
 
-  memcpy(data_out, content+32, st.st_size-32);
-  r = st.st_size - 32;
+  memcpy(data_out, content+32, st_size-32);
+  r = st_size - 32;
 
  end:
   if (content)
-    memwipe(content, 0, st.st_size);
+    memwipe(content, 0, st_size);
   tor_free(content);
   return r;
 }
diff --git a/src/ext/ed25519/ref10/ed25519_ref10.h b/src/ext/ed25519/ref10/ed25519_ref10.h
index 8c77b0e..af7e21a 100644
--- a/src/ext/ed25519/ref10/ed25519_ref10.h
+++ b/src/ext/ed25519/ref10/ed25519_ref10.h
@@ -9,11 +9,11 @@ int ed25519_ref10_pubkey(unsigned char *pk,const unsigned char *sk);
 int ed25519_ref10_keygen(unsigned char *pk,unsigned char *sk);
 int ed25519_ref10_open(
   const unsigned char *signature,
-  const unsigned char *m,uint64_t mlen,
+  const unsigned char *m, size_t mlen,
   const unsigned char *pk);
 int ed25519_ref10_sign(
   unsigned char *sig,
-  const unsigned char *m,uint64_t mlen,
+  const unsigned char *m, size_t mlen,
   const unsigned char *sk, const unsigned char *pk);
 
 /* Added in Tor */
diff --git a/src/ext/ed25519/ref10/open.c b/src/ext/ed25519/ref10/open.c
index 0e7abba..9dbeb4c 100644
--- a/src/ext/ed25519/ref10/open.c
+++ b/src/ext/ed25519/ref10/open.c
@@ -9,7 +9,7 @@
 /* 'signature' must be 64-bytes long. */
 int crypto_sign_open(
   const unsigned char *signature,
-  const unsigned char *m,uint64_t mlen,
+  const unsigned char *m, size_t mlen,
   const unsigned char *pk
 )
 {
diff --git a/src/ext/ed25519/ref10/sign.c b/src/ext/ed25519/ref10/sign.c
index e37b0d1..1190a0f 100644
--- a/src/ext/ed25519/ref10/sign.c
+++ b/src/ext/ed25519/ref10/sign.c
@@ -7,7 +7,7 @@
 
 int crypto_sign(
   unsigned char *sig,
-  const unsigned char *m,uint64_t mlen,
+  const unsigned char *m, size_t mlen,
   const unsigned char *sk,const unsigned char *pk
 )
 {



More information about the tor-commits mailing list