[or-cvs] a few more ints to size_ts

Roger Dingledine arma at seul.org
Wed Oct 13 05:55:01 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common

Modified Files:
	crypto.c crypto.h 
Log Message:
a few more ints to size_ts


Index: crypto.c
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -d -r1.110 -r1.111
--- crypto.c	12 Oct 2004 20:20:19 -0000	1.110
+++ crypto.c	13 Oct 2004 05:54:58 -0000	1.111
@@ -135,7 +135,7 @@
     func = (const char*)ERR_func_error_string(err);
     if (!msg) msg = "(null)";
     if (doing) {
-      log(severity, "crypto error while %s: %s (in %s:%s)", doing, msg, lib,func);
+      log(severity, "crypto error while %s: %s (in %s:%s)", doing, msg, lib, func);
     } else {
       log(severity, "crypto error: %s (in %s:%s)", msg, lib, func);
     }
@@ -377,7 +377,7 @@
  * string, *<b>len</b> to the string's length, and return 0.  On
  * failure, return -1.
  */
-int crypto_pk_write_public_key_to_string(crypto_pk_env_t *env, char **dest, int *len) {
+int crypto_pk_write_public_key_to_string(crypto_pk_env_t *env, char **dest, size_t *len) {
   BUF_MEM *buf;
   BIO *b;
 
@@ -397,6 +397,7 @@
   BIO_set_close(b, BIO_NOCLOSE); /* so BIO_free doesn't free buf */
   BIO_free(b);
 
+  tor_assert(buf->length >= 0);
   *dest = tor_malloc(buf->length+1);
   memcpy(*dest, buf->data, buf->length);
   (*dest)[buf->length] = 0; /* null terminate it */
@@ -410,7 +411,7 @@
  * <b>src</b>, and store the result in <b>env</b>.  Return 0 on success, -1 on
  * failure.
  */
-int crypto_pk_read_public_key_from_string(crypto_pk_env_t *env, const char *src, int len) {
+int crypto_pk_read_public_key_from_string(crypto_pk_env_t *env, const char *src, size_t len) {
   BIO *b;
 
   tor_assert(env && src);
@@ -455,6 +456,7 @@
     return -1;
   }
   len = BIO_get_mem_data(bio, &cp);
+  tor_assert(len >= 0);
   s = tor_malloc(len+1);
   strncpy(s, cp, len);
   s[len] = '\0';
@@ -1473,7 +1475,7 @@
   EVP_ENCODE_CTX ctx;
   int len, ret;
   /* 64 bytes of input -> *up to* 48 bytes of output.
-     Plus one more byte, in caes I'm wrong.
+     Plus one more byte, in case I'm wrong.
   */
   if (destlen < ((srclen/64)+1)*49)
     return -1;

Index: crypto.h
===================================================================
RCS file: /home/or/cvsroot/src/common/crypto.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- crypto.h	12 Oct 2004 20:20:19 -0000	1.53
+++ crypto.h	13 Oct 2004 05:54:58 -0000	1.54
@@ -59,8 +59,8 @@
 /* public key crypto */
 int crypto_pk_generate_key(crypto_pk_env_t *env);
 
-int crypto_pk_write_public_key_to_string(crypto_pk_env_t *env, char **dest, int *len);
-int crypto_pk_read_public_key_from_string(crypto_pk_env_t *env, const char *src, int len);
+int crypto_pk_write_public_key_to_string(crypto_pk_env_t *env, char **dest, size_t *len);
+int crypto_pk_read_public_key_from_string(crypto_pk_env_t *env, const char *src, size_t len);
 int crypto_pk_write_private_key_to_filename(crypto_pk_env_t *env, const char *fname);
 int crypto_pk_check_key(crypto_pk_env_t *env);
 int crypto_pk_read_private_key_from_filename(crypto_pk_env_t *env, const char *keyfile);



More information about the tor-commits mailing list