mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
r9313@totoro: nickm | 2006-11-13 20:07:41 -0500
Try to compile with fewer warnings on irix64's MIPSpro compiler /
environment, which apparently believes that:
- off_t can be bigger than size_t.
- only mean kids assign things they do not subsequently inspect.
I don't try to fix the "error" that makes it say:
cc-3970 cc: WARNING File = main.c, Line = 1277
conversion from pointer to same-sized integral type (potential portability
problem)
uintptr_t sig = (uintptr_t)arg;
Because really, what can you do about a compiler that claims to be c99
but doesn't understand that void* x = NULL; uintptr_t y = (uintptr_t) x;
is safe?
svn:r8948
This commit is contained in:
+1
-1
@@ -135,7 +135,7 @@ tor_mmap_file(const char *filename)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size = filesize = lseek(fd, 0, SEEK_END);
|
||||
size = filesize = (size_t) lseek(fd, 0, SEEK_END);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
/* ensure page alignment */
|
||||
page_size = getpagesize();
|
||||
|
||||
+12
-2
@@ -121,7 +121,12 @@ tor_gzip_compress(char **out, size_t *out_len,
|
||||
out_size *= 2;
|
||||
*out = tor_realloc(*out, out_size);
|
||||
stream->next_out = (unsigned char*)(*out + offset);
|
||||
stream->avail_out = out_size - offset;
|
||||
if (out_size - offset > UINT_MAX) {
|
||||
log_warn(LD_BUG, "Ran over unsigned int limit of zlib while "
|
||||
"uncompressing.");
|
||||
goto err;
|
||||
}
|
||||
stream->avail_out = (unsigned int)(out_size - offset);
|
||||
break;
|
||||
default:
|
||||
log_warn(LD_GENERAL, "Gzip compression didn't finish: %s",
|
||||
@@ -238,7 +243,12 @@ tor_gzip_uncompress(char **out, size_t *out_len,
|
||||
out_size *= 2;
|
||||
*out = tor_realloc(*out, out_size);
|
||||
stream->next_out = (unsigned char*)(*out + offset);
|
||||
stream->avail_out = out_size - offset;
|
||||
if (out_size - offset > UINT_MAX) {
|
||||
log_warn(LD_BUG, "Ran over unsigned int limit of zlib while "
|
||||
"uncompressing.");
|
||||
goto err;
|
||||
}
|
||||
stream->avail_out = (unsigned int)(out_size - offset);
|
||||
break;
|
||||
default:
|
||||
log_warn(LD_GENERAL, "Gzip decompression returned an error: %s",
|
||||
|
||||
@@ -287,6 +287,16 @@ typedef uint32_t uintptr_t;
|
||||
#endif /* time_t_is_signed */
|
||||
#endif /* ifndef(TIME_MAX) */
|
||||
|
||||
#ifndef SIZE_T_MAX
|
||||
#if (SIZEOF_SIZE_T == 4)
|
||||
#define SIZE_T_MAX 0xfffffffful
|
||||
#elif (SIZEOF_SIZE_T == 8)
|
||||
#define SIZE_T_MAX 0xfffffffffffffffful
|
||||
#else
|
||||
#error "Can't define SIZE_T_MAX"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Any size_t larger than this amount is likely to be an underflow. */
|
||||
#define SIZE_T_CEILING (sizeof(char)<<(sizeof(size_t)*8 - 1))
|
||||
|
||||
|
||||
+5
-2
@@ -1324,9 +1324,12 @@ read_file_to_str(const char *filename, int bin, size_t *size_out)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
string = tor_malloc(statbuf.st_size+1);
|
||||
if (statbuf.st_size+1 > SIZE_T_MAX)
|
||||
return NULL;
|
||||
|
||||
r = read_all(fd,string,statbuf.st_size,0);
|
||||
string = tor_malloc((size_t)(statbuf.st_size+1));
|
||||
|
||||
r = read_all(fd,string,(size_t)statbuf.st_size,0);
|
||||
if (r<0) {
|
||||
log_warn(LD_FS,"Error reading from file \"%s\": %s", filename,
|
||||
strerror(errno));
|
||||
|
||||
+1
-1
@@ -3688,7 +3688,7 @@ static const struct {
|
||||
{ "1.1a", LE_11A },
|
||||
{ "1.1b", LE_11B },
|
||||
{ "1.2", LE_12 },
|
||||
{ NULL, 0 }
|
||||
{ NULL, LE_OTHER }
|
||||
};
|
||||
|
||||
static le_version_t
|
||||
|
||||
+6
-2
@@ -1152,7 +1152,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
|
||||
used_quoted_string = 1;
|
||||
}
|
||||
}
|
||||
if (options->CookieAuthentication) {
|
||||
if (options->CookieAuthentication && authentication_cookie_is_set) {
|
||||
if (password_len != AUTHENTICATION_COOKIE_LEN) {
|
||||
log_warn(LD_CONTROL, "Got authentication cookie with wrong length (%d)",
|
||||
(int)password_len);
|
||||
@@ -1685,12 +1685,16 @@ handle_getinfo_helper(control_connection_t *control_conn,
|
||||
} else if (!strcmpstart(question, "dir/server/")) {
|
||||
size_t answer_len = 0, url_len = strlen(question)+2;
|
||||
char *url = tor_malloc(url_len);
|
||||
int res;
|
||||
smartlist_t *descs = smartlist_create();
|
||||
const char *msg;
|
||||
int res;
|
||||
char *cp;
|
||||
tor_snprintf(url, url_len, "/tor/%s", question+4);
|
||||
res = dirserv_get_routerdescs(descs, url, &msg);
|
||||
if (res) {
|
||||
log_warn(LD_CONTROL, "getinfo '%s': %s", question, msg);
|
||||
return -1;
|
||||
}
|
||||
SMARTLIST_FOREACH(descs, signed_descriptor_t *, sd,
|
||||
answer_len += sd->signed_descriptor_len);
|
||||
cp = *answer = tor_malloc(answer_len+1);
|
||||
|
||||
+3
-2
@@ -1953,7 +1953,8 @@ connection_dirserv_add_servers_to_outbuf(dir_connection_t *conn)
|
||||
static int
|
||||
connection_dirserv_add_dir_bytes_to_outbuf(dir_connection_t *conn)
|
||||
{
|
||||
int bytes, remaining;
|
||||
ssize_t bytes;
|
||||
int64_t remaining;
|
||||
|
||||
bytes = DIRSERV_BUFFER_MIN - buf_datalen(conn->_base.outbuf);
|
||||
tor_assert(bytes > 0);
|
||||
@@ -1962,7 +1963,7 @@ connection_dirserv_add_dir_bytes_to_outbuf(dir_connection_t *conn)
|
||||
bytes = 8192;
|
||||
remaining = conn->cached_dir->dir_z_len - conn->cached_dir_offset;
|
||||
if (bytes > remaining)
|
||||
bytes = remaining;
|
||||
bytes = (ssize_t) remaining;
|
||||
|
||||
if (conn->zlib_state) {
|
||||
connection_write_to_buf_zlib(conn,
|
||||
|
||||
+8
-3
@@ -887,6 +887,8 @@ reply_parse(u8 *packet, int length) {
|
||||
GET16(answers);
|
||||
GET16(authority);
|
||||
GET16(additional);
|
||||
(void) authority;
|
||||
(void) additional;
|
||||
|
||||
req = request_find_from_trans_id(trans_id);
|
||||
if (!req) return -1;
|
||||
@@ -1224,7 +1226,7 @@ evdns_request_data_build(const char *const name, const int name_len, const u16 t
|
||||
APPEND16(class);
|
||||
#undef APPEND16
|
||||
|
||||
return j;
|
||||
return (int)j;
|
||||
}
|
||||
|
||||
// this is a libevent callback function which is called when a request
|
||||
@@ -1792,6 +1794,7 @@ search_make_new(const struct search_state *const state, int n, const char *const
|
||||
|
||||
// we ran off the end of the list and still didn't find the requested string
|
||||
abort();
|
||||
return NULL; /* unreachable. */
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -2005,10 +2008,12 @@ evdns_resolv_conf_parse(int flags, const char *const filename) {
|
||||
}
|
||||
if (st.st_size > 65535) { err = 3; goto out1; } // no resolv.conf should be any bigger
|
||||
|
||||
resolv = (u8 *) malloc(st.st_size + 1);
|
||||
resolv = (u8 *) malloc((size_t)st.st_size + 1);
|
||||
if (!resolv) { err = 4; goto out1; }
|
||||
|
||||
if (read(fd, resolv, st.st_size) != st.st_size) { err = 5; goto out2; }
|
||||
if (read(fd, resolv, (size_t)st.st_size) != st.st_size) {
|
||||
err = 5; goto out2;
|
||||
}
|
||||
resolv[st.st_size] = 0; // we malloced an extra byte
|
||||
|
||||
start = (char *) resolv;
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
|
||||
* to avoid buffer overflows? */
|
||||
r = crypto_pk_public_hybrid_encrypt(entry->parsed->pk, payload+DIGEST_LEN,
|
||||
tmp,
|
||||
dh_offset+DH_KEY_LEN,
|
||||
(int)(dh_offset+DH_KEY_LEN),
|
||||
PK_PKCS1_OAEP_PADDING, 0);
|
||||
if (r<0) {
|
||||
log_warn(LD_BUG,"Internal error: hybrid pk encrypt failed.");
|
||||
|
||||
@@ -147,7 +147,7 @@ static struct {
|
||||
{ "client-versions", K_CLIENT_VERSIONS, ARGS, NO_OBJ, NETSTATUS },
|
||||
{ "server-versions", K_SERVER_VERSIONS, ARGS, NO_OBJ, NETSTATUS },
|
||||
{ "eventdns", K_EVENTDNS, ARGS, NO_OBJ, RTR },
|
||||
{ NULL, -1, NO_ARGS, NO_OBJ, ANY }
|
||||
{ NULL, _NIL, NO_ARGS, NO_OBJ, ANY }
|
||||
};
|
||||
|
||||
/* static function prototypes */
|
||||
|
||||
Reference in New Issue
Block a user