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.
|
||||
*/
|
||||
bool
|
||||
expand_buf(struct connection_buffer *buf, unsigned int needed)
|
||||
expand_buf(struct connection_buffer *buf, size_t needed)
|
||||
{
|
||||
void *newdata;
|
||||
debug_decl(expand_buf, SUDO_DEBUG_UTIL);
|
||||
@@ -64,7 +64,7 @@ expand_buf(struct connection_buffer *buf, unsigned int needed)
|
||||
/* Expand buffer. */
|
||||
const size_t newsize = sudo_pow2_roundup(needed);
|
||||
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) {
|
||||
/* overflow */
|
||||
errno = ENOMEM;
|
||||
|
@@ -47,15 +47,15 @@ struct peer_info {
|
||||
struct connection_buffer {
|
||||
TAILQ_ENTRY(connection_buffer) entries;
|
||||
uint8_t *data;
|
||||
unsigned int size;
|
||||
unsigned int len;
|
||||
unsigned int off;
|
||||
size_t size;
|
||||
size_t len;
|
||||
size_t off;
|
||||
};
|
||||
TAILQ_HEAD(connection_buffer_list, connection_buffer);
|
||||
|
||||
/* logsrv_util.c */
|
||||
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_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);
|
||||
while ((buf = TAILQ_FIRST(&closure->write_bufs)) != NULL) {
|
||||
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);
|
||||
free(buf->data);
|
||||
free(buf);
|
||||
@@ -933,7 +933,7 @@ server_msg_cb(int fd, int what, void *v)
|
||||
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);
|
||||
|
||||
#if defined(HAVE_OPENSSL)
|
||||
@@ -983,7 +983,7 @@ server_msg_cb(int fd, int what, void *v)
|
||||
if (buf->off == buf->len) {
|
||||
/* sent entire message, move buf to free list */
|
||||
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->len = 0;
|
||||
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
||||
|
@@ -918,7 +918,7 @@ relay_client_msg_cb(int fd, int what, void *v)
|
||||
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,
|
||||
relay_closure->relay_name.ipaddr);
|
||||
|
||||
@@ -989,7 +989,7 @@ relay_client_msg_cb(int fd, int what, void *v)
|
||||
if (buf->off == buf->len) {
|
||||
/* sent entire message, move buf to free list */
|
||||
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->len = 0;
|
||||
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,
|
||||
"%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 (cert != NULL) {
|
||||
@@ -1473,7 +1473,7 @@ client_msg_cb(int fd, int what, void *v)
|
||||
if (buf->off == buf->len) {
|
||||
/* sent entire message */
|
||||
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->len = 0;
|
||||
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
||||
@@ -1551,7 +1551,7 @@ client_closure_free(struct client_closure *closure)
|
||||
free(closure->buf);
|
||||
while ((buf = TAILQ_FIRST(&closure->write_bufs)) != NULL) {
|
||||
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);
|
||||
free(buf->data);
|
||||
free(buf);
|
||||
|
@@ -1632,7 +1632,7 @@ handle_server_message(uint8_t *buf, size_t len,
|
||||
* XXX - share with logsrvd/sendlog
|
||||
*/
|
||||
static bool
|
||||
expand_buf(struct connection_buffer *buf, unsigned int needed)
|
||||
expand_buf(struct connection_buffer *buf, size_t needed)
|
||||
{
|
||||
void *newdata;
|
||||
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,
|
||||
"%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 (closure->ssl != NULL) {
|
||||
@@ -1910,7 +1910,7 @@ client_msg_cb(int fd, int what, void *v)
|
||||
if (buf->off == buf->len) {
|
||||
/* sent entire message, move buf to free list */
|
||||
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->len = 0;
|
||||
TAILQ_REMOVE(&closure->write_bufs, buf, entries);
|
||||
|
@@ -51,9 +51,9 @@
|
||||
struct connection_buffer {
|
||||
TAILQ_ENTRY(connection_buffer) entries;
|
||||
uint8_t *data;
|
||||
unsigned int size;
|
||||
unsigned int len;
|
||||
unsigned int off;
|
||||
size_t size;
|
||||
size_t len;
|
||||
size_t off;
|
||||
};
|
||||
TAILQ_HEAD(connection_buffer_list, connection_buffer);
|
||||
|
||||
|
Reference in New Issue
Block a user