Promote length/size/offset in struct connection_buffer to size_t.
This commit is contained in:
@@ -55,7 +55,7 @@
|
|||||||
* Expand buf as needed or just reset it.
|
* Expand buf as needed or just reset it.
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
expand_buf(struct connection_buffer *buf, unsigned int needed)
|
expand_buf(struct connection_buffer *buf, size_t needed)
|
||||||
{
|
{
|
||||||
void *newdata;
|
void *newdata;
|
||||||
debug_decl(expand_buf, SUDO_DEBUG_UTIL);
|
debug_decl(expand_buf, SUDO_DEBUG_UTIL);
|
||||||
@@ -64,7 +64,7 @@ expand_buf(struct connection_buffer *buf, unsigned int needed)
|
|||||||
/* Expand buffer. */
|
/* Expand buffer. */
|
||||||
const size_t newsize = sudo_pow2_roundup(needed);
|
const size_t newsize = sudo_pow2_roundup(needed);
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
||||||
"expanding buffer from %u to %zu", buf->size, newsize);
|
"expanding buffer from %zu to %zu", buf->size, newsize);
|
||||||
if (newsize < needed) {
|
if (newsize < needed) {
|
||||||
/* overflow */
|
/* overflow */
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
|
@@ -47,15 +47,15 @@ struct peer_info {
|
|||||||
struct connection_buffer {
|
struct connection_buffer {
|
||||||
TAILQ_ENTRY(connection_buffer) entries;
|
TAILQ_ENTRY(connection_buffer) entries;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
unsigned int size;
|
size_t size;
|
||||||
unsigned int len;
|
size_t len;
|
||||||
unsigned int off;
|
size_t off;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(connection_buffer_list, connection_buffer);
|
TAILQ_HEAD(connection_buffer_list, connection_buffer);
|
||||||
|
|
||||||
/* logsrv_util.c */
|
/* logsrv_util.c */
|
||||||
struct iolog_file;
|
struct iolog_file;
|
||||||
bool expand_buf(struct connection_buffer *buf, unsigned int needed);
|
bool expand_buf(struct connection_buffer *buf, size_t needed);
|
||||||
bool iolog_open_all(int dfd, const char *iolog_dir, struct iolog_file *iolog_files, const char *mode);
|
bool iolog_open_all(int dfd, const char *iolog_dir, struct iolog_file *iolog_files, const char *mode);
|
||||||
bool iolog_seekto(int iolog_dir_fd, const char *iolog_path, struct iolog_file *iolog_files, struct timespec *elapsed_time, const struct timespec *target);
|
bool iolog_seekto(int iolog_dir_fd, const char *iolog_path, struct iolog_file *iolog_files, struct timespec *elapsed_time, const struct timespec *target);
|
||||||
|
|
||||||
|
@@ -141,7 +141,7 @@ connection_closure_free(struct connection_closure *closure)
|
|||||||
free(closure->read_buf.data);
|
free(closure->read_buf.data);
|
||||||
while ((buf = TAILQ_FIRST(&closure->write_bufs)) != NULL) {
|
while ((buf = TAILQ_FIRST(&closure->write_bufs)) != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO,
|
||||||
"discarding write buffer %p, len %u", buf, buf->len - buf->off);
|
"discarding write buffer %p, len %zu", buf, buf->len - buf->off);
|
||||||
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
||||||
free(buf->data);
|
free(buf->data);
|
||||||
free(buf);
|
free(buf);
|
||||||
@@ -933,7 +933,7 @@ server_msg_cb(int fd, int what, void *v)
|
|||||||
goto finished;
|
goto finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: sending %u bytes to client (%s)",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: sending %zu bytes to client (%s)",
|
||||||
__func__, buf->len - buf->off, closure->ipaddr);
|
__func__, buf->len - buf->off, closure->ipaddr);
|
||||||
|
|
||||||
#if defined(HAVE_OPENSSL)
|
#if defined(HAVE_OPENSSL)
|
||||||
@@ -983,7 +983,7 @@ server_msg_cb(int fd, int what, void *v)
|
|||||||
if (buf->off == buf->len) {
|
if (buf->off == buf->len) {
|
||||||
/* sent entire message, move buf to free list */
|
/* sent entire message, move buf to free list */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: finished sending %u bytes to client", __func__, buf->len);
|
"%s: finished sending %zu bytes to client", __func__, buf->len);
|
||||||
buf->off = 0;
|
buf->off = 0;
|
||||||
buf->len = 0;
|
buf->len = 0;
|
||||||
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
||||||
|
@@ -918,7 +918,7 @@ relay_client_msg_cb(int fd, int what, void *v)
|
|||||||
goto close_connection;
|
goto close_connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: sending %u bytes to server %s (%s)",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: sending %zu bytes to server %s (%s)",
|
||||||
__func__, buf->len - buf->off, relay_closure->relay_name.name,
|
__func__, buf->len - buf->off, relay_closure->relay_name.name,
|
||||||
relay_closure->relay_name.ipaddr);
|
relay_closure->relay_name.ipaddr);
|
||||||
|
|
||||||
@@ -989,7 +989,7 @@ relay_client_msg_cb(int fd, int what, void *v)
|
|||||||
if (buf->off == buf->len) {
|
if (buf->off == buf->len) {
|
||||||
/* sent entire message, move buf to free list */
|
/* sent entire message, move buf to free list */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: finished sending %u bytes to server", __func__, buf->len);
|
"%s: finished sending %zu bytes to server", __func__, buf->len);
|
||||||
buf->off = 0;
|
buf->off = 0;
|
||||||
buf->len = 0;
|
buf->len = 0;
|
||||||
TAILQ_REMOVE(&relay_closure->write_bufs, buf, entries);
|
TAILQ_REMOVE(&relay_closure->write_bufs, buf, entries);
|
||||||
|
@@ -1423,7 +1423,7 @@ client_msg_cb(int fd, int what, void *v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: sending %u bytes to server", __func__, buf->len - buf->off);
|
"%s: sending %zu bytes to server", __func__, buf->len - buf->off);
|
||||||
|
|
||||||
#if defined(HAVE_OPENSSL)
|
#if defined(HAVE_OPENSSL)
|
||||||
if (cert != NULL) {
|
if (cert != NULL) {
|
||||||
@@ -1473,7 +1473,7 @@ client_msg_cb(int fd, int what, void *v)
|
|||||||
if (buf->off == buf->len) {
|
if (buf->off == buf->len) {
|
||||||
/* sent entire message */
|
/* sent entire message */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: finished sending %u bytes to server", __func__, buf->len);
|
"%s: finished sending %zu bytes to server", __func__, buf->len);
|
||||||
buf->off = 0;
|
buf->off = 0;
|
||||||
buf->len = 0;
|
buf->len = 0;
|
||||||
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
||||||
@@ -1551,7 +1551,7 @@ client_closure_free(struct client_closure *closure)
|
|||||||
free(closure->buf);
|
free(closure->buf);
|
||||||
while ((buf = TAILQ_FIRST(&closure->write_bufs)) != NULL) {
|
while ((buf = TAILQ_FIRST(&closure->write_bufs)) != NULL) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO,
|
||||||
"discarding write buffer %p, len %u", buf, buf->len - buf->off);
|
"discarding write buffer %p, len %zu", buf, buf->len - buf->off);
|
||||||
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
||||||
free(buf->data);
|
free(buf->data);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
@@ -1632,7 +1632,7 @@ handle_server_message(uint8_t *buf, size_t len,
|
|||||||
* XXX - share with logsrvd/sendlog
|
* XXX - share with logsrvd/sendlog
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
expand_buf(struct connection_buffer *buf, unsigned int needed)
|
expand_buf(struct connection_buffer *buf, size_t needed)
|
||||||
{
|
{
|
||||||
void *newdata;
|
void *newdata;
|
||||||
debug_decl(expand_buf, SUDOERS_DEBUG_UTIL);
|
debug_decl(expand_buf, SUDOERS_DEBUG_UTIL);
|
||||||
@@ -1856,7 +1856,7 @@ client_msg_cb(int fd, int what, void *v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: sending %u bytes to server", __func__, buf->len - buf->off);
|
"%s: sending %zu bytes to server", __func__, buf->len - buf->off);
|
||||||
|
|
||||||
#if defined(HAVE_OPENSSL)
|
#if defined(HAVE_OPENSSL)
|
||||||
if (closure->ssl != NULL) {
|
if (closure->ssl != NULL) {
|
||||||
@@ -1910,7 +1910,7 @@ client_msg_cb(int fd, int what, void *v)
|
|||||||
if (buf->off == buf->len) {
|
if (buf->off == buf->len) {
|
||||||
/* sent entire message, move buf to free list */
|
/* sent entire message, move buf to free list */
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO,
|
sudo_debug_printf(SUDO_DEBUG_INFO,
|
||||||
"%s: finished sending %u bytes to server", __func__, buf->len);
|
"%s: finished sending %zu bytes to server", __func__, buf->len);
|
||||||
buf->off = 0;
|
buf->off = 0;
|
||||||
buf->len = 0;
|
buf->len = 0;
|
||||||
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
||||||
|
@@ -51,9 +51,9 @@
|
|||||||
struct connection_buffer {
|
struct connection_buffer {
|
||||||
TAILQ_ENTRY(connection_buffer) entries;
|
TAILQ_ENTRY(connection_buffer) entries;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
unsigned int size;
|
size_t size;
|
||||||
unsigned int len;
|
size_t len;
|
||||||
unsigned int off;
|
size_t off;
|
||||||
};
|
};
|
||||||
TAILQ_HEAD(connection_buffer_list, connection_buffer);
|
TAILQ_HEAD(connection_buffer_list, connection_buffer);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user