Removed unnecessary casts (mostly dealing with memory allocation.) I
should never have added them in the first place. They don't really buy anything, and they can hide bugs.
This commit is contained in:
parent
bf22966f55
commit
aee5a63849
@ -1,4 +1,4 @@
|
|||||||
/* $Id: acl.c,v 1.17 2003-07-31 23:38:28 rjkaes Exp $
|
/* $Id: acl.c,v 1.18 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This system handles Access Control for use of this daemon. A list of
|
* This system handles Access Control for use of this daemon. A list of
|
||||||
* domains, or IP addresses (including IP blocks) are stored in a list
|
* domains, or IP addresses (including IP blocks) are stored in a list
|
||||||
@ -87,7 +87,7 @@ insert_acl(char *location, acl_access_t access_type)
|
|||||||
rev_acl_ptr = &acl_ptr->next;
|
rev_acl_ptr = &acl_ptr->next;
|
||||||
acl_ptr = acl_ptr->next;
|
acl_ptr = acl_ptr->next;
|
||||||
}
|
}
|
||||||
new_acl_ptr = (struct acl_s*)safemalloc(sizeof(struct acl_s));
|
new_acl_ptr = safemalloc(sizeof(struct acl_s));
|
||||||
if (!new_acl_ptr) {
|
if (!new_acl_ptr) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: buffer.c,v 1.23 2003-07-31 23:38:28 rjkaes Exp $
|
/* $Id: buffer.c,v 1.24 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* The buffer used in each connection is a linked list of lines. As the lines
|
* The buffer used in each connection is a linked list of lines. As the lines
|
||||||
* are read in and written out the buffer expands and contracts. Basically,
|
* are read in and written out the buffer expands and contracts. Basically,
|
||||||
@ -60,10 +60,10 @@ makenewline(unsigned char *data, size_t length)
|
|||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
assert(length > 0);
|
assert(length > 0);
|
||||||
|
|
||||||
if (!(newline = (struct bufline_s*)safemalloc(sizeof(struct bufline_s))))
|
if (!(newline = safemalloc(sizeof(struct bufline_s))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!(newline->string = (unsigned char*)safemalloc(length))) {
|
if (!(newline->string = safemalloc(length))) {
|
||||||
safefree(newline);
|
safefree(newline);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ new_buffer(void)
|
|||||||
{
|
{
|
||||||
struct buffer_s *buffptr;
|
struct buffer_s *buffptr;
|
||||||
|
|
||||||
if (!(buffptr = (struct buffer_s*)safemalloc(sizeof(struct buffer_s))))
|
if (!(buffptr = safemalloc(sizeof(struct buffer_s))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: child.c,v 1.13 2003-08-07 15:31:20 rjkaes Exp $
|
/* $Id: child.c,v 1.14 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Handles the creation/destruction of the various children required for
|
* Handles the creation/destruction of the various children required for
|
||||||
* processing incoming connections.
|
* processing incoming connections.
|
||||||
@ -165,7 +165,7 @@ child_main(struct child_s* ptr)
|
|||||||
struct sockaddr *cliaddr;
|
struct sockaddr *cliaddr;
|
||||||
socklen_t clilen;
|
socklen_t clilen;
|
||||||
|
|
||||||
cliaddr = (struct sockaddr*)safemalloc(addrlen);
|
cliaddr = safemalloc(addrlen);
|
||||||
if (!cliaddr) {
|
if (!cliaddr) {
|
||||||
log_message(LOG_CRIT,
|
log_message(LOG_CRIT,
|
||||||
"Could not allocate memory for child address.");
|
"Could not allocate memory for child address.");
|
||||||
@ -293,15 +293,14 @@ child_pool_create(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
child_ptr = (struct child_s*)calloc_shared_memory(
|
child_ptr = calloc_shared_memory(child_config.maxclients,
|
||||||
child_config.maxclients,
|
|
||||||
sizeof(struct child_s));
|
sizeof(struct child_s));
|
||||||
if (!child_ptr) {
|
if (!child_ptr) {
|
||||||
log_message(LOG_ERR, "Could not allocate memory for children.");
|
log_message(LOG_ERR, "Could not allocate memory for children.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
servers_waiting = (unsigned int*)malloc_shared_memory(sizeof(unsigned int));
|
servers_waiting = malloc_shared_memory(sizeof(unsigned int));
|
||||||
if (servers_waiting == MAP_FAILED) {
|
if (servers_waiting == MAP_FAILED) {
|
||||||
log_message(LOG_ERR, "Could not allocate memory for child counting.");
|
log_message(LOG_ERR, "Could not allocate memory for child counting.");
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: conns.c,v 1.20 2004-01-26 19:11:51 rjkaes Exp $
|
/* $Id: conns.c,v 1.21 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Create and free the connection structure. One day there could be
|
* Create and free the connection structure. One day there could be
|
||||||
* other connection related tasks put here, but for now the header
|
* other connection related tasks put here, but for now the header
|
||||||
@ -46,7 +46,7 @@ initialize_conn(int client_fd, const char* ipaddr, const char* string_addr)
|
|||||||
/*
|
/*
|
||||||
* Allocate the space for the conn_s structure itself.
|
* Allocate the space for the conn_s structure itself.
|
||||||
*/
|
*/
|
||||||
connptr = (struct conn_s*)safemalloc(sizeof(struct conn_s));
|
connptr = safemalloc(sizeof(struct conn_s));
|
||||||
if (!connptr)
|
if (!connptr)
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: filter.c,v 1.19 2003-10-17 16:11:00 rjkaes Exp $
|
/* $Id: filter.c,v 1.20 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 1999 George Talusan (gstalusan@uwaterloo.ca)
|
* Copyright (c) 1999 George Talusan (gstalusan@uwaterloo.ca)
|
||||||
* Copyright (c) 2002 James E. Flemer (jflemer@acm.jhu.edu)
|
* Copyright (c) 2002 James E. Flemer (jflemer@acm.jhu.edu)
|
||||||
@ -106,7 +106,7 @@ filter_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p->pat = safestrdup(s);
|
p->pat = safestrdup(s);
|
||||||
p->cpat = (regex_t*)safemalloc(sizeof(regex_t));
|
p->cpat = safemalloc(sizeof(regex_t));
|
||||||
if ((err = regcomp(p->cpat, p->pat, cflags)) != 0) {
|
if ((err = regcomp(p->cpat, p->pat, cflags)) != 0) {
|
||||||
fprintf(stderr, "Bad regex in %s: %s\n",
|
fprintf(stderr, "Bad regex in %s: %s\n",
|
||||||
config.filter, p->pat);
|
config.filter, p->pat);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: hashmap.c,v 1.13 2003-07-31 23:38:28 rjkaes Exp $
|
/* $Id: hashmap.c,v 1.14 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* A hashmap implementation. The keys are case-insensitive NULL terminated
|
* A hashmap implementation. The keys are case-insensitive NULL terminated
|
||||||
* strings, and the data is arbitrary lumps of data. Copies of both the
|
* strings, and the data is arbitrary lumps of data. Copies of both the
|
||||||
@ -97,14 +97,12 @@ hashmap_create(unsigned int nbuckets)
|
|||||||
if (nbuckets == 0)
|
if (nbuckets == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ptr = (struct hashmap_s*)safecalloc(1, sizeof(struct hashmap_s));
|
ptr = safecalloc(1, sizeof(struct hashmap_s));
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ptr->size = nbuckets;
|
ptr->size = nbuckets;
|
||||||
ptr->buckets =
|
ptr->buckets = safecalloc(nbuckets, sizeof(struct hashentry_s *));
|
||||||
(struct hashentry_s**)safecalloc(nbuckets,
|
|
||||||
sizeof(struct hashentry_s *));
|
|
||||||
if (!ptr->buckets) {
|
if (!ptr->buckets) {
|
||||||
safefree(ptr);
|
safefree(ptr);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -225,7 +223,7 @@ hashmap_insert(hashmap_t map, const char *key,
|
|||||||
data_copy = NULL;
|
data_copy = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = (struct hashentry_s*)safemalloc(sizeof(struct hashentry_s));
|
ptr = safemalloc(sizeof(struct hashentry_s));
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
safefree(key_copy);
|
safefree(key_copy);
|
||||||
safefree(data_copy);
|
safefree(data_copy);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: heap.c,v 1.7 2003-07-31 23:42:51 rjkaes Exp $
|
/* $Id: heap.c,v 1.8 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Debugging versions of various heap related functions are combined
|
* Debugging versions of various heap related functions are combined
|
||||||
* here. The debugging versions include assertions and also print
|
* here. The debugging versions include assertions and also print
|
||||||
@ -82,7 +82,7 @@ debugging_strdup(const char* s, const char* file, unsigned long line)
|
|||||||
assert(s != NULL);
|
assert(s != NULL);
|
||||||
|
|
||||||
len = strlen(s) + 1;
|
len = strlen(s) + 1;
|
||||||
ptr = (char*)malloc(len);
|
ptr = malloc(len);
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return NULL;
|
return NULL;
|
||||||
memcpy(ptr, s, len);
|
memcpy(ptr, s, len);
|
||||||
@ -113,11 +113,11 @@ malloc_shared_memory(size_t size)
|
|||||||
strlcpy(buffer, shared_file, sizeof(buffer));
|
strlcpy(buffer, shared_file, sizeof(buffer));
|
||||||
|
|
||||||
if ((fd = mkstemp(buffer)) == -1)
|
if ((fd = mkstemp(buffer)) == -1)
|
||||||
return (void *)MAP_FAILED;
|
return MAP_FAILED;
|
||||||
unlink(buffer);
|
unlink(buffer);
|
||||||
|
|
||||||
if (ftruncate(fd, size) == -1)
|
if (ftruncate(fd, size) == -1)
|
||||||
return (void *)MAP_FAILED;
|
return MAP_FAILED;
|
||||||
ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
|
ptr = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: http_message.c,v 1.3 2003-07-31 23:38:28 rjkaes Exp $
|
/* $Id: http_message.c,v 1.4 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* See 'http_message.h' for a detailed description.
|
* See 'http_message.h' for a detailed description.
|
||||||
*
|
*
|
||||||
@ -81,11 +81,11 @@ http_message_create(int response_code, const char* response_string)
|
|||||||
http_message_t msg;
|
http_message_t msg;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
msg = (http_message_t)safecalloc(1, sizeof(struct http_message_s));
|
msg = safecalloc(1, sizeof(struct http_message_s));
|
||||||
if (msg == NULL)
|
if (msg == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
msg->headers.strings = (char**)safecalloc(NUMBER_OF_HEADERS, sizeof(char*));
|
msg->headers.strings = safecalloc(NUMBER_OF_HEADERS, sizeof(char*));
|
||||||
if (msg->headers.strings == NULL) {
|
if (msg->headers.strings == NULL) {
|
||||||
safefree(msg);
|
safefree(msg);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -182,7 +182,7 @@ http_message_add_headers(http_message_t msg, char** headers,
|
|||||||
* available, reallocate the memory.
|
* available, reallocate the memory.
|
||||||
*/
|
*/
|
||||||
if (msg->headers.used + num_headers > msg->headers.total) {
|
if (msg->headers.used + num_headers > msg->headers.total) {
|
||||||
new_headers = (char**)safecalloc(msg->headers.total * 2,
|
new_headers = safecalloc(msg->headers.total * 2,
|
||||||
sizeof(char*));
|
sizeof(char*));
|
||||||
if (new_headers == NULL)
|
if (new_headers == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: log.c,v 1.27 2003-07-31 23:38:28 rjkaes Exp $
|
/* $Id: log.c,v 1.28 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Logs the various messages which tinyproxy produces to either a log file or
|
* Logs the various messages which tinyproxy produces to either a log file or
|
||||||
* the syslog daemon. Not much to it...
|
* the syslog daemon. Not much to it...
|
||||||
@ -143,7 +143,7 @@ log_message(int level, char *fmt, ...)
|
|||||||
|
|
||||||
vsnprintf(str, STRING_LENGTH, fmt, args);
|
vsnprintf(str, STRING_LENGTH, fmt, args);
|
||||||
|
|
||||||
entry_buffer = (char*)safemalloc(strlen(str) + 6);
|
entry_buffer = safemalloc(strlen(str) + 6);
|
||||||
if (!entry_buffer)
|
if (!entry_buffer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ send_stored_logs(void)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i != vector_length(log_message_storage); ++i) {
|
for (i = 0; i != vector_length(log_message_storage); ++i) {
|
||||||
string = (char*)vector_getentry(log_message_storage, i, NULL);
|
string = vector_getentry(log_message_storage, i, NULL);
|
||||||
|
|
||||||
ptr = strchr(string, ' ') + 1;
|
ptr = strchr(string, ' ') + 1;
|
||||||
level = atoi(string);
|
level = atoi(string);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: network.c,v 1.2 2003-07-31 23:38:28 rjkaes Exp $
|
/* $Id: network.c,v 1.3 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* The functions found here are used for communicating across a
|
* The functions found here are used for communicating across a
|
||||||
* network. They include both safe reading and writing (which are
|
* network. They include both safe reading and writing (which are
|
||||||
@ -90,7 +90,7 @@ write_message(int fd, const char *fmt, ...)
|
|||||||
char *buf, *tmpbuf;
|
char *buf, *tmpbuf;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if ((buf = (char*)safemalloc(size)) == NULL)
|
if ((buf = safemalloc(size)) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -110,7 +110,7 @@ write_message(int fd, const char *fmt, ...)
|
|||||||
/* twice the old size (glibc2.0) */
|
/* twice the old size (glibc2.0) */
|
||||||
size *= 2;
|
size *= 2;
|
||||||
|
|
||||||
if ((tmpbuf = (char*)saferealloc(buf, size)) == NULL) {
|
if ((tmpbuf = saferealloc(buf, size)) == NULL) {
|
||||||
safefree(buf);
|
safefree(buf);
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else
|
||||||
@ -154,8 +154,7 @@ readline(int fd, char **whole_buffer)
|
|||||||
};
|
};
|
||||||
struct read_lines_s *first_line, *line_ptr;
|
struct read_lines_s *first_line, *line_ptr;
|
||||||
|
|
||||||
first_line =
|
first_line = safecalloc(sizeof(struct read_lines_s), 1);
|
||||||
(struct read_lines_s*)safecalloc(sizeof(struct read_lines_s), 1);
|
|
||||||
if (!first_line)
|
if (!first_line)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -167,7 +166,7 @@ readline(int fd, char **whole_buffer)
|
|||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
goto CLEANUP;
|
goto CLEANUP;
|
||||||
|
|
||||||
ptr = (char*)memchr(buffer, '\n', ret);
|
ptr = memchr(buffer, '\n', ret);
|
||||||
if (ptr)
|
if (ptr)
|
||||||
diff = ptr - buffer + 1;
|
diff = ptr - buffer + 1;
|
||||||
else
|
else
|
||||||
@ -184,7 +183,7 @@ readline(int fd, char **whole_buffer)
|
|||||||
goto CLEANUP;
|
goto CLEANUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
line_ptr->data = (char*)safemalloc(diff);
|
line_ptr->data = safemalloc(diff);
|
||||||
if (!line_ptr->data) {
|
if (!line_ptr->data) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto CLEANUP;
|
goto CLEANUP;
|
||||||
@ -198,8 +197,7 @@ readline(int fd, char **whole_buffer)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
line_ptr->next =
|
line_ptr->next = safecalloc(sizeof(struct read_lines_s), 1);
|
||||||
(struct read_lines_s*)safecalloc(sizeof(struct read_lines_s), 1);
|
|
||||||
if (!line_ptr->next) {
|
if (!line_ptr->next) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto CLEANUP;
|
goto CLEANUP;
|
||||||
@ -207,7 +205,7 @@ readline(int fd, char **whole_buffer)
|
|||||||
line_ptr = line_ptr->next;
|
line_ptr = line_ptr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
*whole_buffer = (char*)safemalloc(whole_buffer_len + 1);
|
*whole_buffer = safemalloc(whole_buffer_len + 1);
|
||||||
if (!*whole_buffer) {
|
if (!*whole_buffer) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto CLEANUP;
|
goto CLEANUP;
|
||||||
|
23
src/reqs.c
23
src/reqs.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: reqs.c,v 1.110 2004-02-04 19:57:40 rjkaes Exp $
|
/* $Id: reqs.c,v 1.111 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This is where all the work in tinyproxy is actually done. Incoming
|
* This is where all the work in tinyproxy is actually done. Incoming
|
||||||
* connections have a new child created for them. The child then
|
* connections have a new child created for them. The child then
|
||||||
@ -127,7 +127,7 @@ check_allowed_connect_ports(int port)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i != vector_length(ports_allowed_by_connect); ++i) {
|
for (i = 0; i != vector_length(ports_allowed_by_connect); ++i) {
|
||||||
data = (int*)vector_getentry(ports_allowed_by_connect, i, NULL);
|
data = vector_getentry(ports_allowed_by_connect, i, NULL);
|
||||||
if (!data)
|
if (!data)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ extract_http_url(const char *url, struct request_s *request)
|
|||||||
static int
|
static int
|
||||||
extract_ssl_url(const char *url, struct request_s *request)
|
extract_ssl_url(const char *url, struct request_s *request)
|
||||||
{
|
{
|
||||||
request->host = (char*)safemalloc(strlen(url) + 1);
|
request->host = safemalloc(strlen(url) + 1);
|
||||||
if (!request->host)
|
if (!request->host)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -339,8 +339,7 @@ void
|
|||||||
upstream_add(const char *host, int port, const char *domain)
|
upstream_add(const char *host, int port, const char *domain)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
struct upstream *up =
|
struct upstream *up = safemalloc(sizeof (struct upstream));
|
||||||
(struct upstream*)safemalloc(sizeof (struct upstream));
|
|
||||||
|
|
||||||
if (!up) {
|
if (!up) {
|
||||||
log_message(LOG_ERR, "Unable to allocate memory in upstream_add()");
|
log_message(LOG_ERR, "Unable to allocate memory in upstream_add()");
|
||||||
@ -613,15 +612,15 @@ process_request(struct conn_s *connptr, hashmap_t hashofheaders)
|
|||||||
size_t request_len;
|
size_t request_len;
|
||||||
|
|
||||||
/* NULL out all the fields so frees don't cause segfaults. */
|
/* NULL out all the fields so frees don't cause segfaults. */
|
||||||
request = (struct request_s*)safecalloc(1, sizeof(struct request_s));
|
request = safecalloc(1, sizeof(struct request_s));
|
||||||
if (!request)
|
if (!request)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
request_len = strlen(connptr->request_line) + 1;
|
request_len = strlen(connptr->request_line) + 1;
|
||||||
|
|
||||||
request->method = (char*)safemalloc(request_len);
|
request->method = safemalloc(request_len);
|
||||||
url = (char*)safemalloc(request_len);
|
url = safemalloc(request_len);
|
||||||
request->protocol = (char*)safemalloc(request_len);
|
request->protocol = safemalloc(request_len);
|
||||||
|
|
||||||
if (!request->method || !url || !request->protocol) {
|
if (!request->method || !url || !request->protocol) {
|
||||||
safefree(url);
|
safefree(url);
|
||||||
@ -926,7 +925,7 @@ pull_client_data(struct conn_s *connptr, long int length)
|
|||||||
char *buffer;
|
char *buffer;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
buffer = (char*)safemalloc(min(MAXBUFFSIZE, length));
|
buffer = safemalloc(min(MAXBUFFSIZE, length));
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -1633,7 +1632,7 @@ connect_to_upstream(struct conn_s *connptr, struct request_s *request)
|
|||||||
if (connptr->connect_method) {
|
if (connptr->connect_method) {
|
||||||
len = strlen(request->host) + 7;
|
len = strlen(request->host) + 7;
|
||||||
|
|
||||||
combined_string = (char*)safemalloc(len);
|
combined_string = safemalloc(len);
|
||||||
if (!combined_string) {
|
if (!combined_string) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1642,7 +1641,7 @@ connect_to_upstream(struct conn_s *connptr, struct request_s *request)
|
|||||||
request->port);
|
request->port);
|
||||||
} else {
|
} else {
|
||||||
len = strlen(request->host) + strlen(request->path) + 14;
|
len = strlen(request->host) + strlen(request->path) + 14;
|
||||||
combined_string = (char*)safemalloc(len);
|
combined_string = safemalloc(len);
|
||||||
if (!combined_string) {
|
if (!combined_string) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: stats.c,v 1.14 2003-07-31 23:38:28 rjkaes Exp $
|
/* $Id: stats.c,v 1.15 2004-02-13 21:27:42 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This module handles the statistics for tinyproxy. There are only two
|
* This module handles the statistics for tinyproxy. There are only two
|
||||||
* public API functions. The reason for the functions, rather than just a
|
* public API functions. The reason for the functions, rather than just a
|
||||||
@ -45,7 +45,7 @@ static struct stat_s *stats;
|
|||||||
void
|
void
|
||||||
init_stats(void)
|
init_stats(void)
|
||||||
{
|
{
|
||||||
stats = (struct stat_s*)malloc_shared_memory(sizeof(struct stat_s));
|
stats = malloc_shared_memory(sizeof(struct stat_s));
|
||||||
if (stats == MAP_FAILED)
|
if (stats == MAP_FAILED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ showstats(struct conn_s *connptr)
|
|||||||
snprintf(refused, sizeof(refused), "%lu", stats->num_refused);
|
snprintf(refused, sizeof(refused), "%lu", stats->num_refused);
|
||||||
|
|
||||||
if (!config.statpage || (!(statfile = fopen(config.statpage, "r")))) {
|
if (!config.statpage || (!(statfile = fopen(config.statpage, "r")))) {
|
||||||
message_buffer = (char*)safemalloc(MAXBUFFSIZE);
|
message_buffer = safemalloc(MAXBUFFSIZE);
|
||||||
if (!message_buffer)
|
if (!message_buffer)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Id: vector.c,v 1.10 2003-07-31 23:38:28 rjkaes Exp $
|
/* $Id: vector.c,v 1.11 2004-02-13 21:27:41 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* A vector implementation. The vector can be of an arbitrary length, and
|
* A vector implementation. The vector can be of an arbitrary length, and
|
||||||
* the data for each entry is an lump of data (the size is stored in the
|
* the data for each entry is an lump of data (the size is stored in the
|
||||||
@ -58,7 +58,7 @@ vector_create(void)
|
|||||||
{
|
{
|
||||||
vector_t vector;
|
vector_t vector;
|
||||||
|
|
||||||
vector = (vector_t)safemalloc(sizeof(struct vector_s));
|
vector = safemalloc(sizeof(struct vector_s));
|
||||||
if (!vector)
|
if (!vector)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ vector_insert(vector_t vector, void *data, ssize_t len, int pos)
|
|||||||
(pos != INSERT_PREPEND && pos != INSERT_APPEND))
|
(pos != INSERT_PREPEND && pos != INSERT_APPEND))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
entry = (struct vectorentry_s*)safemalloc(sizeof(struct vectorentry_s));
|
entry = safemalloc(sizeof(struct vectorentry_s));
|
||||||
if (!entry)
|
if (!entry)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user