1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 09:27:59 +00:00

Make lots of 'int' length fields into size_t.

This is a general cleanup which has been overdue for some time: lots
of length fields are now the machine word type rather than the (in
practice) fixed 'int'.
This commit is contained in:
Simon Tatham 2019-02-06 20:42:44 +00:00
parent f60fe670ad
commit 0cda34c6f8
52 changed files with 312 additions and 285 deletions

View File

@ -39,7 +39,7 @@ static void agentf_callback(void *vctx, void *reply, int replylen);
static void agentf_try_forward(agentf *af)
{
unsigned datalen, length;
size_t datalen, length;
strbuf *message;
unsigned char msglen[4];
void *reply;
@ -142,7 +142,7 @@ static void agentf_callback(void *vctx, void *reply, int replylen)
}
static void agentf_free(Channel *chan);
static int agentf_send(Channel *chan, bool is_stderr, const void *, int);
static size_t agentf_send(Channel *chan, bool is_stderr, const void *, size_t);
static void agentf_send_eof(Channel *chan);
static char *agentf_log_close_msg(Channel *chan);
static void agentf_set_input_wanted(Channel *chan, bool wanted);
@ -196,8 +196,8 @@ static void agentf_free(Channel *chan)
sfree(af);
}
static int agentf_send(Channel *chan, bool is_stderr,
const void *data, int length)
static size_t agentf_send(Channel *chan, bool is_stderr,
const void *data, size_t length)
{
assert(chan->vt == &agentf_channelvt);
agentf *af = container_of(chan, agentf, chan);

View File

@ -59,11 +59,10 @@ void backend_socket_log(Seat *seat, LogContext *logctx,
}
}
void log_proxy_stderr(Plug *plug, bufchain *buf, const void *vdata, int len)
void log_proxy_stderr(Plug *plug, bufchain *buf, const void *vdata, size_t len)
{
const char *data = (const char *)vdata;
int pos = 0;
int msglen;
size_t pos = 0;
const char *nlpos;
char *msg, *fullmsg;
@ -88,7 +87,8 @@ void log_proxy_stderr(Plug *plug, bufchain *buf, const void *vdata, int len)
/*
* Collect the resulting line of data and pass it to plug_log.
*/
msglen = bufchain_size(buf);
size_t msglen = bufchain_size(buf);
assert(msglen < ~(size_t)0);
msg = snewn(msglen+1, char);
bufchain_fetch(buf, msg, msglen);
bufchain_consume(buf, msglen);

View File

@ -31,7 +31,7 @@ static Filename *xlatlognam(Filename *s, char *hostname, int port,
* isn't open, buffering data if it's in the process of being
* opened asynchronously, etc.
*/
static void logwrite(LogContext *ctx, const void *data, int len)
static void logwrite(LogContext *ctx, const void *data, size_t len)
{
/*
* In state L_CLOSED, we call logfopen, which will set the state
@ -45,7 +45,7 @@ static void logwrite(LogContext *ctx, const void *data, int len)
bufchain_add(&ctx->queue, data, len);
} else if (ctx->state == L_OPEN) {
assert(ctx->lgfp);
if (fwrite(data, 1, len, ctx->lgfp) < (size_t)len) {
if (fwrite(data, 1, len, ctx->lgfp) < len) {
logfclose(ctx);
ctx->state = L_ERROR;
lp_eventlog(ctx->lp, "Disabled writing session log "
@ -138,7 +138,7 @@ static void logfopen_callback(void *vctx, int mode)
assert(ctx->state != L_OPENING); /* make _sure_ it won't be requeued */
while (bufchain_size(&ctx->queue)) {
void *data;
int len;
size_t len;
bufchain_prefix(&ctx->queue, &data, &len);
logwrite(ctx, data, len);
bufchain_consume(&ctx->queue, len);
@ -276,13 +276,13 @@ void logeventf(LogContext *ctx, const char *fmt, ...)
* Set of blanking areas must be in increasing order.
*/
void log_packet(LogContext *ctx, int direction, int type,
const char *texttype, const void *data, int len,
const char *texttype, const void *data, size_t len,
int n_blanks, const struct logblank_t *blanks,
const unsigned long *seq,
unsigned downstream_id, const char *additional_log_text)
{
char dumpdata[80], smalldata[5];
int p = 0, b = 0, omitted = 0;
char dumpdata[128], smalldata[5];
size_t p = 0, b = 0, omitted = 0;
int output_pos = 0; /* NZ if pending output in dumpdata */
if (!(ctx->logtype == LGTYP_SSHRAW ||
@ -354,7 +354,7 @@ void log_packet(LogContext *ctx, int direction, int type,
/* (Re-)initialise dumpdata as necessary
* (start of row, or if we've just stopped omitting) */
if (!output_pos && !omitted)
sprintf(dumpdata, " %08x%*s\r\n", p-(p%16), 1+3*16+2+16, "");
sprintf(dumpdata, " %08zx%*s\r\n", p-(p%16), 1+3*16+2+16, "");
/* Deal with the current byte. */
if (blktype == PKTLOG_OMIT) {

View File

@ -14,7 +14,8 @@
static void mainchan_free(Channel *chan);
static void mainchan_open_confirmation(Channel *chan);
static void mainchan_open_failure(Channel *chan, const char *errtext);
static int mainchan_send(Channel *chan, bool is_stderr, const void *, int);
static size_t mainchan_send(
Channel *chan, bool is_stderr, const void *, size_t);
static void mainchan_send_eof(Channel *chan);
static void mainchan_set_input_wanted(Channel *chan, bool wanted);
static char *mainchan_log_close_msg(Channel *chan);
@ -362,8 +363,8 @@ static void mainchan_open_failure(Channel *chan, const char *errtext)
queue_toplevel_callback(mainchan_open_failure_abort, ctx);
}
static int mainchan_send(Channel *chan, bool is_stderr,
const void *data, int length)
static size_t mainchan_send(Channel *chan, bool is_stderr,
const void *data, size_t length)
{
assert(chan->vt == &mainchan_channelvt);
mainchan *mc = container_of(chan, mainchan, chan);

4
misc.c
View File

@ -307,8 +307,8 @@ char *buildinfo(const char *newline)
return strbuf_to_str(buf);
}
int nullseat_output(
Seat *seat, bool is_stderr, const void *data, int len) { return 0; }
size_t nullseat_output(
Seat *seat, bool is_stderr, const void *data, size_t len) { return 0; }
bool nullseat_eof(Seat *seat) { return true; }
int nullseat_get_userpass_input(
Seat *seat, prompts_t *p, bufchain *input) { return 0; }

20
misc.h
View File

@ -95,7 +95,7 @@ int base64_decode_atom(const char *atom, unsigned char *out);
struct bufchain_granule;
struct bufchain_tag {
struct bufchain_granule *head, *tail;
int buffersize; /* current amount of buffered data */
size_t buffersize; /* current amount of buffered data */
void (*queue_idempotent_callback)(IdempotentCallback *ic);
IdempotentCallback *ic;
@ -103,14 +103,14 @@ struct bufchain_tag {
void bufchain_init(bufchain *ch);
void bufchain_clear(bufchain *ch);
int bufchain_size(bufchain *ch);
void bufchain_add(bufchain *ch, const void *data, int len);
void bufchain_prefix(bufchain *ch, void **data, int *len);
void bufchain_consume(bufchain *ch, int len);
void bufchain_fetch(bufchain *ch, void *data, int len);
void bufchain_fetch_consume(bufchain *ch, void *data, int len);
bool bufchain_try_fetch_consume(bufchain *ch, void *data, int len);
int bufchain_fetch_consume_up_to(bufchain *ch, void *data, int len);
size_t bufchain_size(bufchain *ch);
void bufchain_add(bufchain *ch, const void *data, size_t len);
void bufchain_prefix(bufchain *ch, void **data, size_t *len);
void bufchain_consume(bufchain *ch, size_t len);
void bufchain_fetch(bufchain *ch, void *data, size_t len);
void bufchain_fetch_consume(bufchain *ch, void *data, size_t len);
bool bufchain_try_fetch_consume(bufchain *ch, void *data, size_t len);
size_t bufchain_fetch_consume_up_to(bufchain *ch, void *data, size_t len);
void bufchain_set_callback_inner(
bufchain *ch, IdempotentCallback *ic,
void (*queue_idempotent_callback)(IdempotentCallback *ic));
@ -125,7 +125,7 @@ static inline void bufchain_set_callback(bufchain *ch, IdempotentCallback *ic)
bufchain_set_callback_inner(ch, ic, queue_idempotent_callback);
}
void sanitise_term_data(bufchain *out, const void *vdata, int len);
void sanitise_term_data(bufchain *out, const void *vdata, size_t len);
bool validate_manual_hostkey(char *key);

View File

@ -28,8 +28,8 @@ struct SocketVtable {
/* if p is NULL, it doesn't change the plug */
/* but it does return the one it's using */
void (*close) (Socket *s);
int (*write) (Socket *s, const void *data, int len);
int (*write_oob) (Socket *s, const void *data, int len);
size_t (*write) (Socket *s, const void *data, size_t len);
size_t (*write_oob) (Socket *s, const void *data, size_t len);
void (*write_eof) (Socket *s);
void (*flush) (Socket *s);
void (*set_frozen) (Socket *s, bool is_frozen);
@ -70,7 +70,7 @@ struct PlugVtable {
/* error_msg is NULL iff it is not an error (ie it closed normally) */
/* calling_back != 0 iff there is a Plug function */
/* currently running (would cure the fixme in try_send()) */
void (*receive) (Plug *p, int urgent, const char *data, int len);
void (*receive) (Plug *p, int urgent, const char *data, size_t len);
/*
* - urgent==0. `data' points to `len' bytes of perfectly
* ordinary data.
@ -81,7 +81,7 @@ struct PlugVtable {
* - urgent==2. `data' points to `len' bytes of data,
* the first of which was the one at the Urgent mark.
*/
void (*sent) (Plug *p, int bufsize);
void (*sent) (Plug *p, size_t bufsize);
/*
* The `sent' function is called when the pending send backlog
* on a socket is cleared or partially cleared. The new backlog
@ -279,6 +279,7 @@ void backend_socket_log(Seat *seat, LogContext *logctx,
int type, SockAddr *addr, int port,
const char *error_msg, int error_code, Conf *conf,
bool session_started);
void log_proxy_stderr(Plug *plug, bufchain *buf, const void *vdata, int len);
void log_proxy_stderr(
Plug *plug, bufchain *buf, const void *vdata, size_t len);
#endif

View File

@ -17,11 +17,12 @@ static void nullplug_closing(Plug *plug, const char *error_msg, int error_code,
{
}
static void nullplug_receive(Plug *plug, int urgent, const char *data, int len)
static void nullplug_receive(
Plug *plug, int urgent, const char *data, size_t len)
{
}
static void nullplug_sent(Plug *plug, int bufsize)
static void nullplug_sent(Plug *plug, size_t bufsize)
{
}

View File

@ -733,7 +733,7 @@ static void pageant_conn_closing(Plug *plug, const char *error_msg,
sfree(pc);
}
static void pageant_conn_sent(Plug *plug, int bufsize)
static void pageant_conn_sent(Plug *plug, size_t bufsize)
{
/* struct pageant_conn_state *pc = container_of(
plug, struct pageant_conn_state, plug); */
@ -756,7 +756,7 @@ static void pageant_conn_log(void *logctx, const char *fmt, va_list ap)
}
static void pageant_conn_receive(
Plug *plug, int urgent, const char *data, int len)
Plug *plug, int urgent, const char *data, size_t len)
{
struct pageant_conn_state *pc = container_of(
plug, struct pageant_conn_state, plug);

View File

@ -192,7 +192,7 @@ static char *ipv6_to_string(ptrlen ipv6)
(unsigned)GET_16BIT_MSB_FIRST(addr + 14));
}
static void pfd_receive(Plug *plug, int urgent, const char *data, int len)
static void pfd_receive(Plug *plug, int urgent, const char *data, size_t len)
{
struct PortForwarding *pf =
container_of(plug, struct PortForwarding, plug);
@ -417,7 +417,7 @@ static void pfd_receive(Plug *plug, int urgent, const char *data, int len)
sshfwd_write(pf->c, data, len);
}
static void pfd_sent(Plug *plug, int bufsize)
static void pfd_sent(Plug *plug, size_t bufsize)
{
struct PortForwarding *pf =
container_of(plug, struct PortForwarding, plug);
@ -437,7 +437,8 @@ static const PlugVtable PortForwarding_plugvt = {
static void pfd_chan_free(Channel *chan);
static void pfd_open_confirmation(Channel *chan);
static void pfd_open_failure(Channel *chan, const char *errtext);
static int pfd_send(Channel *chan, bool is_stderr, const void *data, int len);
static size_t pfd_send(
Channel *chan, bool is_stderr, const void *data, size_t len);
static void pfd_send_eof(Channel *chan);
static void pfd_set_input_wanted(Channel *chan, bool wanted);
static char *pfd_log_close_msg(Channel *chan);
@ -644,7 +645,8 @@ static void pfd_chan_free(Channel *chan)
/*
* Called to send data down the raw connection.
*/
static int pfd_send(Channel *chan, bool is_stderr, const void *data, int len)
static size_t pfd_send(
Channel *chan, bool is_stderr, const void *data, size_t len)
{
assert(chan->vt == &PortForwarding_channelvt);
PortForwarding *pf = container_of(chan, PortForwarding, chan);

21
proxy.c
View File

@ -25,8 +25,7 @@
void proxy_activate (ProxySocket *p)
{
void *data;
int len;
long output_before, output_after;
size_t len, output_before, output_after;
p->state = PROXY_STATE_ACTIVE;
@ -95,7 +94,7 @@ static void sk_proxy_close (Socket *s)
sfree(ps);
}
static int sk_proxy_write (Socket *s, const void *data, int len)
static size_t sk_proxy_write (Socket *s, const void *data, size_t len)
{
ProxySocket *ps = container_of(s, ProxySocket, sock);
@ -106,7 +105,7 @@ static int sk_proxy_write (Socket *s, const void *data, int len)
return sk_write(ps->sub_socket, data, len);
}
static int sk_proxy_write_oob (Socket *s, const void *data, int len)
static size_t sk_proxy_write_oob (Socket *s, const void *data, size_t len)
{
ProxySocket *ps = container_of(s, ProxySocket, sock);
@ -162,7 +161,7 @@ static void sk_proxy_set_frozen (Socket *s, bool is_frozen)
while (!ps->freeze && bufchain_size(&ps->pending_input_data) > 0) {
void *data;
char databuf[512];
int len;
size_t len;
bufchain_prefix(&ps->pending_input_data, &data, &len);
if (len > lenof(databuf))
len = lenof(databuf);
@ -214,7 +213,8 @@ static void plug_proxy_closing (Plug *p, const char *error_msg,
}
}
static void plug_proxy_receive (Plug *p, int urgent, const char *data, int len)
static void plug_proxy_receive(
Plug *p, int urgent, const char *data, size_t len)
{
ProxySocket *ps = container_of(p, ProxySocket, plugimpl);
@ -233,7 +233,7 @@ static void plug_proxy_receive (Plug *p, int urgent, const char *data, int len)
}
}
static void plug_proxy_sent (Plug *p, int bufsize)
static void plug_proxy_sent (Plug *p, size_t bufsize)
{
ProxySocket *ps = container_of(p, ProxySocket, plugimpl);
@ -544,9 +544,9 @@ Socket *new_listener(const char *srcaddr, int port, Plug *plug,
* HTTP CONNECT proxy type.
*/
static bool get_line_end(char *data, int len, int *out)
static bool get_line_end(char *data, size_t len, size_t *out)
{
int off = 0;
size_t off = 0;
while (off < len)
{
@ -661,8 +661,7 @@ int proxy_http_negotiate (ProxySocket *p, int change)
*/
char *data, *datap;
int len;
int eol;
size_t len, eol;
if (p->state == 1) {

15
pscp.c
View File

@ -60,7 +60,7 @@ const char *const appname = "PSCP";
void ldisc_echoedit_update(Ldisc *ldisc) { }
static int pscp_output(Seat *, bool is_stderr, const void *, int);
static size_t pscp_output(Seat *, bool is_stderr, const void *, size_t);
static bool pscp_eof(Seat *);
static const SeatVtable pscp_seat_vt = {
@ -145,7 +145,8 @@ void agent_schedule_callback(void (*callback)(void *, void *, int),
*/
static bufchain received_data;
static int pscp_output(Seat *seat, bool is_stderr, const void *data, int len)
static size_t pscp_output(
Seat *seat, bool is_stderr, const void *data, size_t len)
{
/*
* stderr data is just spouted to local stderr and otherwise
@ -175,7 +176,7 @@ static bool pscp_eof(Seat *seat)
}
return false;
}
static bool ssh_scp_recv(void *vbuf, int len)
static bool ssh_scp_recv(void *vbuf, size_t len)
{
char *buf = (char *)vbuf;
while (len > 0) {
@ -185,7 +186,7 @@ static bool ssh_scp_recv(void *vbuf, int len)
return false; /* doom */
}
int got = bufchain_fetch_consume_up_to(&received_data, buf, len);
size_t got = bufchain_fetch_consume_up_to(&received_data, buf, len);
buf += got;
len -= got;
}
@ -570,16 +571,16 @@ static int response(void)
}
}
bool sftp_recvdata(char *buf, int len)
bool sftp_recvdata(char *buf, size_t len)
{
return ssh_scp_recv(buf, len);
}
bool sftp_senddata(const char *buf, int len)
bool sftp_senddata(const char *buf, size_t len)
{
backend_send(backend, buf, len);
return true;
}
int sftp_sendbuffer(void)
size_t sftp_sendbuffer(void)
{
return backend_sendbuffer(backend);
}

13
psftp.c
View File

@ -41,7 +41,7 @@ bool sent_eof = false;
* Seat vtable.
*/
static int psftp_output(Seat *, bool is_stderr, const void *, int);
static size_t psftp_output(Seat *, bool is_stderr, const void *, size_t);
static bool psftp_eof(Seat *);
static const SeatVtable psftp_seat_vt = {
@ -2446,7 +2446,8 @@ void agent_schedule_callback(void (*callback)(void *, void *, int),
*/
static bufchain received_data;
static int psftp_output(Seat *seat, bool is_stderr, const void *data, int len)
static size_t psftp_output(
Seat *seat, bool is_stderr, const void *data, size_t len)
{
/*
* stderr data is just spouted to local stderr and otherwise
@ -2477,7 +2478,7 @@ static bool psftp_eof(Seat *seat)
return false;
}
bool sftp_recvdata(char *buf, int len)
bool sftp_recvdata(char *buf, size_t len)
{
while (len > 0) {
while (bufchain_size(&received_data) == 0) {
@ -2486,19 +2487,19 @@ bool sftp_recvdata(char *buf, int len)
return false; /* doom */
}
int got = bufchain_fetch_consume_up_to(&received_data, buf, len);
size_t got = bufchain_fetch_consume_up_to(&received_data, buf, len);
buf += got;
len -= got;
}
return true;
}
bool sftp_senddata(const char *buf, int len)
bool sftp_senddata(const char *buf, size_t len)
{
backend_send(backend, buf, len);
return true;
}
int sftp_sendbuffer(void)
size_t sftp_sendbuffer(void)
{
return backend_sendbuffer(backend);
}

15
putty.h
View File

@ -503,9 +503,9 @@ struct BackendVtable {
/* Pass in a replacement configuration. */
void (*reconfig) (Backend *be, Conf *conf);
/* send() returns the current amount of buffered data. */
int (*send) (Backend *be, const char *buf, int len);
size_t (*send) (Backend *be, const char *buf, size_t len);
/* sendbuffer() does the same thing but without attempting a send */
int (*sendbuffer) (Backend *be);
size_t (*sendbuffer) (Backend *be);
void (*size) (Backend *be, int width, int height);
void (*special) (Backend *be, SessionSpecialCode code, int arg);
const SessionSpecial *(*get_specials) (Backend *be);
@ -518,7 +518,7 @@ struct BackendVtable {
bool (*ldisc_option_state) (Backend *be, int);
void (*provide_ldisc) (Backend *be, Ldisc *ldisc);
/* Tells the back end that the front end buffer is clearing. */
void (*unthrottle) (Backend *be, int bufsize);
void (*unthrottle) (Backend *be, size_t bufsize);
int (*cfg_info) (Backend *be);
/* Only implemented in the SSH protocol: check whether a
@ -742,7 +742,7 @@ struct SeatVtable {
*
* The return value is the current size of the output backlog.
*/
int (*output)(Seat *seat, bool is_stderr, const void *data, int len);
size_t (*output)(Seat *seat, bool is_stderr, const void *data, size_t len);
/*
* Called when the back end wants to indicate that EOF has arrived
@ -964,7 +964,8 @@ void seat_connection_fatal(Seat *seat, const char *fmt, ...);
* These are generally obvious, except for is_utf8, where you might
* plausibly want to return either fixed answer 'no' or 'yes'.
*/
int nullseat_output(Seat *seat, bool is_stderr, const void *data, int len);
size_t nullseat_output(
Seat *seat, bool is_stderr, const void *data, size_t len);
bool nullseat_eof(Seat *seat);
int nullseat_get_userpass_input(Seat *seat, prompts_t *p, bufchain *input);
void nullseat_notify_remote_exit(Seat *seat);
@ -1546,7 +1547,7 @@ void term_reconfig(Terminal *, Conf *);
void term_request_copy(Terminal *, const int *clipboards, int n_clipboards);
void term_request_paste(Terminal *, int clipboard);
void term_seen_key_event(Terminal *);
int term_data(Terminal *, bool is_stderr, const void *data, int len);
size_t term_data(Terminal *, bool is_stderr, const void *data, size_t len);
void term_provide_backend(Terminal *term, Backend *backend);
void term_provide_logctx(Terminal *term, LogContext *logctx);
void term_set_focus(Terminal *term, bool has_focus);
@ -1634,7 +1635,7 @@ struct logblank_t {
int type;
};
void log_packet(LogContext *logctx, int direction, int type,
const char *texttype, const void *data, int len,
const char *texttype, const void *data, size_t len,
int n_blanks, const struct logblank_t *blanks,
const unsigned long *sequence,
unsigned downstream_id, const char *additional_log_text);

16
raw.c
View File

@ -14,7 +14,7 @@ typedef struct Raw Raw;
struct Raw {
Socket *s;
bool closed_on_socket_error;
int bufsize;
size_t bufsize;
Seat *seat;
LogContext *logctx;
bool sent_console_eof, sent_socket_eof, session_started;
@ -27,9 +27,9 @@ struct Raw {
static void raw_size(Backend *be, int width, int height);
static void c_write(Raw *raw, const void *buf, int len)
static void c_write(Raw *raw, const void *buf, size_t len)
{
int backlog = seat_stdout(raw->seat, buf, len);
size_t backlog = seat_stdout(raw->seat, buf, len);
sk_set_frozen(raw->s, backlog > RAW_MAX_BACKLOG);
}
@ -89,7 +89,7 @@ static void raw_closing(Plug *plug, const char *error_msg, int error_code,
}
}
static void raw_receive(Plug *plug, int urgent, const char *data, int len)
static void raw_receive(Plug *plug, int urgent, const char *data, size_t len)
{
Raw *raw = container_of(plug, Raw, plug);
c_write(raw, data, len);
@ -98,7 +98,7 @@ static void raw_receive(Plug *plug, int urgent, const char *data, int len)
raw->session_started = true;
}
static void raw_sent(Plug *plug, int bufsize)
static void raw_sent(Plug *plug, size_t bufsize)
{
Raw *raw = container_of(plug, Raw, plug);
raw->bufsize = bufsize;
@ -201,7 +201,7 @@ static void raw_reconfig(Backend *be, Conf *conf)
/*
* Called to send data down the raw connection.
*/
static int raw_send(Backend *be, const char *buf, int len)
static size_t raw_send(Backend *be, const char *buf, size_t len)
{
Raw *raw = container_of(be, Raw, backend);
@ -216,7 +216,7 @@ static int raw_send(Backend *be, const char *buf, int len)
/*
* Called to query the current socket sendability status.
*/
static int raw_sendbuffer(Backend *be)
static size_t raw_sendbuffer(Backend *be)
{
Raw *raw = container_of(be, Raw, backend);
return raw->bufsize;
@ -266,7 +266,7 @@ static bool raw_sendok(Backend *be)
return true;
}
static void raw_unthrottle(Backend *be, int backlog)
static void raw_unthrottle(Backend *be, size_t backlog)
{
Raw *raw = container_of(be, Raw, backend);
sk_set_frozen(raw->s, backlog > RAW_MAX_BACKLOG);

View File

@ -31,9 +31,9 @@ struct Rlogin {
Backend backend;
};
static void c_write(Rlogin *rlogin, const void *buf, int len)
static void c_write(Rlogin *rlogin, const void *buf, size_t len)
{
int backlog = seat_stdout(rlogin->seat, buf, len);
size_t backlog = seat_stdout(rlogin->seat, buf, len);
sk_set_frozen(rlogin->s, backlog > RLOGIN_MAX_BACKLOG);
}
@ -71,7 +71,8 @@ static void rlogin_closing(Plug *plug, const char *error_msg, int error_code,
} /* Otherwise, the remote side closed the connection normally. */
}
static void rlogin_receive(Plug *plug, int urgent, const char *data, int len)
static void rlogin_receive(
Plug *plug, int urgent, const char *data, size_t len)
{
Rlogin *rlogin = container_of(plug, Rlogin, plug);
if (len == 0)
@ -110,7 +111,7 @@ static void rlogin_receive(Plug *plug, int urgent, const char *data, int len)
}
}
static void rlogin_sent(Plug *plug, int bufsize)
static void rlogin_sent(Plug *plug, size_t bufsize)
{
Rlogin *rlogin = container_of(plug, Rlogin, plug);
rlogin->bufsize = bufsize;
@ -260,7 +261,7 @@ static void rlogin_reconfig(Backend *be, Conf *conf)
/*
* Called to send data down the rlogin connection.
*/
static int rlogin_send(Backend *be, const char *buf, int len)
static size_t rlogin_send(Backend *be, const char *buf, size_t len)
{
Rlogin *rlogin = container_of(be, Rlogin, backend);
bufchain bc;
@ -287,7 +288,7 @@ static int rlogin_send(Backend *be, const char *buf, int len)
if (!rlogin->prompt) {
while (bufchain_size(&bc) > 0) {
void *data;
int len;
size_t len;
bufchain_prefix(&bc, &data, &len);
rlogin->bufsize = sk_write(rlogin->s, data, len);
bufchain_consume(&bc, len);
@ -302,7 +303,7 @@ static int rlogin_send(Backend *be, const char *buf, int len)
/*
* Called to query the current socket sendability status.
*/
static int rlogin_sendbuffer(Backend *be)
static size_t rlogin_sendbuffer(Backend *be)
{
Rlogin *rlogin = container_of(be, Rlogin, backend);
return rlogin->bufsize;
@ -360,7 +361,7 @@ static bool rlogin_sendok(Backend *be)
return true;
}
static void rlogin_unthrottle(Backend *be, int backlog)
static void rlogin_unthrottle(Backend *be, size_t backlog)
{
Rlogin *rlogin = container_of(be, Rlogin, backend);
sk_set_frozen(rlogin->s, backlog > RLOGIN_MAX_BACKLOG);

View File

@ -481,7 +481,7 @@ static void scp_source_push_name(
}
static void scp_source_free(ScpServer *s);
static int scp_source_send(ScpServer *s, const void *data, size_t length);
static size_t scp_source_send(ScpServer *s, const void *data, size_t length);
static void scp_source_eof(ScpServer *s);
static void scp_source_throttle(ScpServer *s, bool throttled);
@ -859,7 +859,7 @@ static void scp_source_process_stack(ScpSource *scp)
scp_requeue(scp);
}
static int scp_source_send(ScpServer *s, const void *vdata, size_t length)
static size_t scp_source_send(ScpServer *s, const void *vdata, size_t length)
{
ScpSource *scp = container_of(s, ScpSource, scpserver);
const char *data = (const char *)vdata;
@ -994,7 +994,7 @@ static void scp_sink_pop(ScpSink *scp)
}
static void scp_sink_free(ScpServer *s);
static int scp_sink_send(ScpServer *s, const void *data, size_t length);
static size_t scp_sink_send(ScpServer *s, const void *data, size_t length);
static void scp_sink_eof(ScpServer *s);
static void scp_sink_throttle(ScpServer *s, bool throttled) {}
@ -1078,7 +1078,7 @@ static void scp_sink_coroutine(ScpSink *scp)
goto done;
void *vdata;
int len;
size_t len;
const char *cdata, *newline;
bufchain_prefix(&scp->data, &vdata, &len);
@ -1180,7 +1180,7 @@ static void scp_sink_coroutine(ScpSink *scp)
scp->file_offset = 0;
while (scp->file_offset < scp->file_size) {
void *vdata;
int len;
size_t len;
uint64_t this_len, remaining;
crMaybeWaitUntilV(
@ -1258,7 +1258,7 @@ static void scp_sink_coroutine(ScpSink *scp)
crFinishV;
}
static int scp_sink_send(ScpServer *s, const void *data, size_t length)
static size_t scp_sink_send(ScpServer *s, const void *data, size_t length)
{
ScpSink *scp = container_of(s, ScpSink, scpserver);
@ -1292,7 +1292,7 @@ struct ScpError {
static void scp_error_free(ScpServer *s);
static int scp_error_send(ScpServer *s, const void *data, size_t length)
static size_t scp_error_send(ScpServer *s, const void *data, size_t length)
{ return 0; }
static void scp_error_eof(ScpServer *s) {}
static void scp_error_throttle(ScpServer *s, bool throttled) {}

View File

@ -48,7 +48,8 @@ typedef struct sesschan {
} sesschan;
static void sesschan_free(Channel *chan);
static int sesschan_send(Channel *chan, bool is_stderr, const void *, int);
static size_t sesschan_send(
Channel *chan, bool is_stderr, const void *, size_t);
static void sesschan_send_eof(Channel *chan);
static char *sesschan_log_close_msg(Channel *chan);
static bool sesschan_want_close(Channel *, bool, bool);
@ -95,7 +96,8 @@ static const struct ChannelVtable sesschan_channelvt = {
chan_no_request_response,
};
static int sftp_chan_send(Channel *chan, bool is_stderr, const void *, int);
static size_t sftp_chan_send(
Channel *chan, bool is_stderr, const void *, size_t);
static void sftp_chan_send_eof(Channel *chan);
static char *sftp_log_close_msg(Channel *chan);
@ -124,7 +126,8 @@ static const struct ChannelVtable sftp_channelvt = {
chan_no_request_response,
};
static int scp_chan_send(Channel *chan, bool is_stderr, const void *, int);
static size_t scp_chan_send(
Channel *chan, bool is_stderr, const void *, size_t);
static void scp_chan_send_eof(Channel *chan);
static void scp_set_input_wanted(Channel *chan, bool wanted);
static char *scp_log_close_msg(Channel *chan);
@ -166,7 +169,8 @@ static const LogPolicyVtable sesschan_logpolicy_vt = {
sesschan_logging_error,
};
static int sesschan_seat_output(Seat *, bool is_stderr, const void *, int);
static size_t sesschan_seat_output(
Seat *, bool is_stderr, const void *, size_t);
static bool sesschan_seat_eof(Seat *);
static void sesschan_notify_remote_exit(Seat *seat);
static void sesschan_connection_fatal(Seat *seat, const char *message);
@ -241,8 +245,8 @@ static void sesschan_free(Channel *chan)
sfree(sess);
}
static int sesschan_send(Channel *chan, bool is_stderr,
const void *data, int length)
static size_t sesschan_send(Channel *chan, bool is_stderr,
const void *data, size_t length)
{
sesschan *sess = container_of(chan, sesschan, chan);
@ -553,8 +557,8 @@ bool sesschan_change_window_size(
return true;
}
static int sesschan_seat_output(
Seat *seat, bool is_stderr, const void *data, int len)
static size_t sesschan_seat_output(
Seat *seat, bool is_stderr, const void *data, size_t len)
{
sesschan *sess = container_of(seat, sesschan, seat);
return sshfwd_write_ext(sess->c, is_stderr, data, len);
@ -647,8 +651,8 @@ static bool sesschan_get_window_pixel_size(Seat *seat, int *width, int *height)
* Built-in SFTP subsystem.
*/
static int sftp_chan_send(Channel *chan, bool is_stderr,
const void *data, int length)
static size_t sftp_chan_send(Channel *chan, bool is_stderr,
const void *data, size_t length)
{
sesschan *sess = container_of(chan, sesschan, chan);
@ -695,8 +699,8 @@ static char *sftp_log_close_msg(Channel *chan)
* Built-in SCP subsystem.
*/
static int scp_chan_send(Channel *chan, bool is_stderr,
const void *data, int length)
static size_t scp_chan_send(Channel *chan, bool is_stderr,
const void *data, size_t length)
{
sesschan *sess = container_of(chan, sesschan, chan);
return scp_send(sess->scpsrv, data, length);

8
sftp.h
View File

@ -70,9 +70,9 @@
* sftp_sendbuffer returns the size of the backlog of data in the
* transmit queue.
*/
bool sftp_senddata(const char *data, int len);
int sftp_sendbuffer(void);
bool sftp_recvdata(char *data, int len);
bool sftp_senddata(const char *data, size_t len);
size_t sftp_sendbuffer(void);
bool sftp_recvdata(char *data, size_t len);
/*
* Free sftp_requests
@ -494,7 +494,7 @@ struct ScpServer {
struct ScpServerVtable {
void (*free)(ScpServer *s);
int (*send)(ScpServer *s, const void *data, size_t length);
size_t (*send)(ScpServer *s, const void *data, size_t length);
void (*throttle)(ScpServer *s, bool throttled);
void (*eof)(ScpServer *s);
};

20
ssh.c
View File

@ -61,7 +61,7 @@ struct Ssh {
int version;
int conn_throttle_count;
int overall_bufsize;
size_t overall_bufsize;
bool throttled_all;
/*
@ -139,7 +139,7 @@ struct Ssh {
logevent_and_free((ssh)->logctx, dupprintf params))
static void ssh_shutdown(Ssh *ssh);
static void ssh_throttle_all(Ssh *ssh, bool enable, int bufsize);
static void ssh_throttle_all(Ssh *ssh, bool enable, size_t bufsize);
static void ssh_bpp_output_raw_data_callback(void *vctx);
LogContext *ssh_get_logctx(Ssh *ssh)
@ -349,7 +349,7 @@ static void ssh_bpp_output_raw_data_callback(void *vctx)
while (bufchain_size(&ssh->out_raw) > 0) {
void *data;
int len, backlog;
size_t len, backlog;
bufchain_prefix(&ssh->out_raw, &data, &len);
@ -573,7 +573,7 @@ static void ssh_closing(Plug *plug, const char *error_msg, int error_code,
}
}
static void ssh_receive(Plug *plug, int urgent, const char *data, int len)
static void ssh_receive(Plug *plug, int urgent, const char *data, size_t len)
{
Ssh *ssh = container_of(plug, Ssh, plug);
@ -589,7 +589,7 @@ static void ssh_receive(Plug *plug, int urgent, const char *data, int len)
ssh_check_frozen(ssh);
}
static void ssh_sent(Plug *plug, int bufsize)
static void ssh_sent(Plug *plug, size_t bufsize)
{
Ssh *ssh = container_of(plug, Ssh, plug);
/*
@ -810,7 +810,7 @@ void ssh_throttle_conn(Ssh *ssh, int adjust)
* Throttle or unthrottle _all_ local data streams (for when sends
* on the SSH connection itself back up).
*/
static void ssh_throttle_all(Ssh *ssh, bool enable, int bufsize)
static void ssh_throttle_all(Ssh *ssh, bool enable, size_t bufsize)
{
if (enable == ssh->throttled_all)
return;
@ -928,7 +928,7 @@ static void ssh_reconfig(Backend *be, Conf *conf)
/*
* Called to send data down the SSH connection.
*/
static int ssh_send(Backend *be, const char *buf, int len)
static size_t ssh_send(Backend *be, const char *buf, size_t len)
{
Ssh *ssh = container_of(be, Ssh, backend);
@ -945,10 +945,10 @@ static int ssh_send(Backend *be, const char *buf, int len)
/*
* Called to query the current amount of buffered stdin data.
*/
static int ssh_sendbuffer(Backend *be)
static size_t ssh_sendbuffer(Backend *be)
{
Ssh *ssh = container_of(be, Ssh, backend);
int backlog;
size_t backlog;
if (!ssh || !ssh->s || !ssh->cl)
return 0;
@ -1049,7 +1049,7 @@ static void ssh_special(Backend *be, SessionSpecialCode code, int arg)
* This is called when the seat's output channel manages to clear some
* backlog.
*/
static void ssh_unthrottle(Backend *be, int bufsize)
static void ssh_unthrottle(Backend *be, size_t bufsize)
{
Ssh *ssh = container_of(be, Ssh, backend);

4
ssh.h
View File

@ -271,10 +271,10 @@ struct ConnectionLayerVtable {
void (*terminal_size)(ConnectionLayer *cl, int width, int height);
/* Indicate that the backlog on standard output has cleared */
void (*stdout_unthrottle)(ConnectionLayer *cl, int bufsize);
void (*stdout_unthrottle)(ConnectionLayer *cl, size_t bufsize);
/* Query the size of the backlog on standard _input_ */
int (*stdin_backlog)(ConnectionLayer *cl);
size_t (*stdin_backlog)(ConnectionLayer *cl);
/* Tell the connection layer that the SSH connection itself has
* backed up, so it should tell all currently open channels to

View File

@ -396,8 +396,8 @@ static void ssh1mainchan_hint_channel_is_simple(SshChannel *sc)
{
}
static int ssh1mainchan_write(
SshChannel *sc, bool is_stderr, const void *data, int len)
static size_t ssh1mainchan_write(
SshChannel *sc, bool is_stderr, const void *data, size_t len)
{
struct ssh1_connection_state *s =
container_of(sc, struct ssh1_connection_state, mainchan_sc);

View File

@ -13,8 +13,8 @@
#include "ssh1connection.h"
#include "sshserver.h"
static int ssh1sesschan_write(SshChannel *c, bool is_stderr,
const void *, int);
static size_t ssh1sesschan_write(SshChannel *c, bool is_stderr,
const void *, size_t);
static void ssh1sesschan_write_eof(SshChannel *c);
static void ssh1sesschan_initiate_close(SshChannel *c, const char *err);
static void ssh1sesschan_send_exit_status(SshChannel *c, int status);
@ -274,8 +274,8 @@ struct ssh_rportfwd *ssh1_rportfwd_alloc(
unreachable("Should never be called in the server");
}
static int ssh1sesschan_write(SshChannel *sc, bool is_stderr,
const void *data, int len)
static size_t ssh1sesschan_write(SshChannel *sc, bool is_stderr,
const void *data, size_t len)
{
struct ssh1_connection_state *s =
container_of(sc, struct ssh1_connection_state, mainchan_sc);

View File

@ -55,8 +55,8 @@ static struct X11FakeAuth *ssh1_add_x11_display(
ConnectionLayer *cl, int authtype, struct X11Display *disp);
static bool ssh1_agent_forwarding_permitted(ConnectionLayer *cl);
static void ssh1_terminal_size(ConnectionLayer *cl, int width, int height);
static void ssh1_stdout_unthrottle(ConnectionLayer *cl, int bufsize);
static int ssh1_stdin_backlog(ConnectionLayer *cl);
static void ssh1_stdout_unthrottle(ConnectionLayer *cl, size_t bufsize);
static size_t ssh1_stdin_backlog(ConnectionLayer *cl);
static void ssh1_throttle_all_channels(ConnectionLayer *cl, bool throttled);
static bool ssh1_ldisc_option(ConnectionLayer *cl, int option);
static void ssh1_set_ldisc_option(ConnectionLayer *cl, int option, bool value);
@ -91,11 +91,11 @@ static const struct ConnectionLayerVtable ssh1_connlayer_vtable = {
ssh1_set_wants_user_input,
};
static int ssh1channel_write(
SshChannel *c, bool is_stderr, const void *buf, int len);
static size_t ssh1channel_write(
SshChannel *c, bool is_stderr, const void *buf, size_t len);
static void ssh1channel_write_eof(SshChannel *c);
static void ssh1channel_initiate_close(SshChannel *c, const char *err);
static void ssh1channel_unthrottle(SshChannel *c, int bufsize);
static void ssh1channel_unthrottle(SshChannel *c, size_t bufsize);
static Conf *ssh1channel_get_conf(SshChannel *c);
static void ssh1channel_window_override_removed(SshChannel *c) { /* ignore */ }
@ -578,7 +578,7 @@ static void ssh1channel_initiate_close(SshChannel *sc, const char *err)
ssh1_channel_check_close(c);
}
static void ssh1channel_unthrottle(SshChannel *sc, int bufsize)
static void ssh1channel_unthrottle(SshChannel *sc, size_t bufsize)
{
struct ssh1_channel *c = container_of(sc, struct ssh1_channel, sc);
struct ssh1_connection_state *s = c->connlayer;
@ -589,8 +589,8 @@ static void ssh1channel_unthrottle(SshChannel *sc, int bufsize)
}
}
static int ssh1channel_write(
SshChannel *sc, bool is_stderr, const void *buf, int len)
static size_t ssh1channel_write(
SshChannel *sc, bool is_stderr, const void *buf, size_t len)
{
struct ssh1_channel *c = container_of(sc, struct ssh1_channel, sc);
struct ssh1_connection_state *s = c->connlayer;
@ -695,7 +695,7 @@ static void ssh1_terminal_size(ConnectionLayer *cl, int width, int height)
mainchan_terminal_size(s->mainchan, width, height);
}
static void ssh1_stdout_unthrottle(ConnectionLayer *cl, int bufsize)
static void ssh1_stdout_unthrottle(ConnectionLayer *cl, size_t bufsize)
{
struct ssh1_connection_state *s =
container_of(cl, struct ssh1_connection_state, cl);
@ -706,7 +706,7 @@ static void ssh1_stdout_unthrottle(ConnectionLayer *cl, int bufsize)
}
}
static int ssh1_stdin_backlog(ConnectionLayer *cl)
static size_t ssh1_stdin_backlog(ConnectionLayer *cl)
{
return 0;
}
@ -781,7 +781,7 @@ static void ssh1_connection_got_user_input(PacketProtocolLayer *ppl)
* Add user input to the main channel's buffer.
*/
void *data;
int len;
size_t len;
bufchain_prefix(s->ppl.user_input, &data, &len);
if (len > 512)
len = 512;

View File

@ -55,8 +55,8 @@ static void ssh2_sharing_queue_global_request(
static void ssh2_sharing_no_more_downstreams(ConnectionLayer *cl);
static bool ssh2_agent_forwarding_permitted(ConnectionLayer *cl);
static void ssh2_terminal_size(ConnectionLayer *cl, int width, int height);
static void ssh2_stdout_unthrottle(ConnectionLayer *cl, int bufsize);
static int ssh2_stdin_backlog(ConnectionLayer *cl);
static void ssh2_stdout_unthrottle(ConnectionLayer *cl, size_t bufsize);
static size_t ssh2_stdin_backlog(ConnectionLayer *cl);
static void ssh2_throttle_all_channels(ConnectionLayer *cl, bool throttled);
static bool ssh2_ldisc_option(ConnectionLayer *cl, int option);
static void ssh2_set_ldisc_option(ConnectionLayer *cl, int option, bool value);
@ -118,11 +118,11 @@ static char *ssh2_channel_open_failure_error_text(PktIn *pktin)
return dupprintf("%s [%.*s]", reason_code_string, PTRLEN_PRINTF(reason));
}
static int ssh2channel_write(
SshChannel *c, bool is_stderr, const void *buf, int len);
static size_t ssh2channel_write(
SshChannel *c, bool is_stderr, const void *buf, size_t len);
static void ssh2channel_write_eof(SshChannel *c);
static void ssh2channel_initiate_close(SshChannel *c, const char *err);
static void ssh2channel_unthrottle(SshChannel *c, int bufsize);
static void ssh2channel_unthrottle(SshChannel *c, size_t bufsize);
static Conf *ssh2channel_get_conf(SshChannel *c);
static void ssh2channel_window_override_removed(SshChannel *c);
static void ssh2channel_x11_sharing_handover(
@ -158,7 +158,7 @@ static const struct SshChannelVtable ssh2channel_vtable = {
static void ssh2_channel_check_close(struct ssh2_channel *c);
static void ssh2_channel_try_eof(struct ssh2_channel *c);
static void ssh2_set_window(struct ssh2_channel *c, int newwin);
static int ssh2_try_send(struct ssh2_channel *c);
static size_t ssh2_try_send(struct ssh2_channel *c);
static void ssh2_try_send_and_unthrottle(struct ssh2_channel *c);
static void ssh2_channel_check_throttle(struct ssh2_channel *c);
static void ssh2_channel_close_local(struct ssh2_channel *c,
@ -1055,24 +1055,24 @@ static void ssh2_channel_try_eof(struct ssh2_channel *c)
/*
* Attempt to send data on an SSH-2 channel.
*/
static int ssh2_try_send(struct ssh2_channel *c)
static size_t ssh2_try_send(struct ssh2_channel *c)
{
struct ssh2_connection_state *s = c->connlayer;
PktOut *pktout;
int bufsize;
size_t bufsize;
while (c->remwindow > 0 &&
(bufchain_size(&c->outbuffer) > 0 ||
bufchain_size(&c->errbuffer) > 0)) {
int len;
size_t len;
void *data;
bufchain *buf = (bufchain_size(&c->errbuffer) > 0 ?
&c->errbuffer : &c->outbuffer);
bufchain_prefix(buf, &data, &len);
if ((unsigned)len > c->remwindow)
if (len > c->remwindow)
len = c->remwindow;
if ((unsigned)len > c->remmaxpkt)
if (len > c->remmaxpkt)
len = c->remmaxpkt;
if (buf == &c->errbuffer) {
pktout = ssh_bpp_new_pktout(
@ -1322,11 +1322,11 @@ static void ssh2channel_initiate_close(SshChannel *sc, const char *err)
ssh2_channel_check_close(c);
}
static void ssh2channel_unthrottle(SshChannel *sc, int bufsize)
static void ssh2channel_unthrottle(SshChannel *sc, size_t bufsize)
{
struct ssh2_channel *c = container_of(sc, struct ssh2_channel, sc);
struct ssh2_connection_state *s = c->connlayer;
int buflimit;
size_t buflimit;
buflimit = s->ssh_is_simple ? 0 : c->locmaxwin;
if (bufsize < buflimit)
@ -1338,8 +1338,8 @@ static void ssh2channel_unthrottle(SshChannel *sc, int bufsize)
}
}
static int ssh2channel_write(
SshChannel *sc, bool is_stderr, const void *buf, int len)
static size_t ssh2channel_write(
SshChannel *sc, bool is_stderr, const void *buf, size_t len)
{
struct ssh2_channel *c = container_of(sc, struct ssh2_channel, sc);
assert(!(c->closes & CLOSES_SENT_EOF));
@ -1578,7 +1578,7 @@ static void ssh2_terminal_size(ConnectionLayer *cl, int width, int height)
mainchan_terminal_size(s->mainchan, width, height);
}
static void ssh2_stdout_unthrottle(ConnectionLayer *cl, int bufsize)
static void ssh2_stdout_unthrottle(ConnectionLayer *cl, size_t bufsize)
{
struct ssh2_connection_state *s =
container_of(cl, struct ssh2_connection_state, cl);
@ -1587,7 +1587,7 @@ static void ssh2_stdout_unthrottle(ConnectionLayer *cl, int bufsize)
sshfwd_unthrottle(s->mainchan_sc, bufsize);
}
static int ssh2_stdin_backlog(ConnectionLayer *cl)
static size_t ssh2_stdin_backlog(ConnectionLayer *cl)
{
struct ssh2_connection_state *s =
container_of(cl, struct ssh2_connection_state, cl);
@ -1671,7 +1671,7 @@ static void ssh2_connection_got_user_input(PacketProtocolLayer *ppl)
* Add user input to the main channel's buffer.
*/
void *data;
int len;
size_t len;
bufchain_prefix(s->ppl.user_input, &data, &len);
sshfwd_write(s->mainchan_sc, data, len);
bufchain_consume(s->ppl.user_input, len);

View File

@ -466,7 +466,7 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
(flags & (FLAG_VERBOSE | FLAG_INTERACTIVE))) {
while (bufchain_size(&s->banner) > 0) {
void *data;
int len;
size_t len;
bufchain_prefix(&s->banner, &data, &len);
seat_stderr(s->ppl.seat, data, len);
bufchain_consume(&s->banner, len);

View File

@ -19,7 +19,7 @@ struct ChannelVtable {
void (*open_confirmation)(Channel *);
void (*open_failed)(Channel *, const char *error_text);
int (*send)(Channel *, bool is_stderr, const void *buf, int len);
size_t (*send)(Channel *, bool is_stderr, const void *buf, size_t len);
void (*send_eof)(Channel *);
void (*set_input_wanted)(Channel *, bool wanted);
@ -156,10 +156,10 @@ Channel *zombiechan_new(void);
*/
struct SshChannelVtable {
int (*write)(SshChannel *c, bool is_stderr, const void *, int);
size_t (*write)(SshChannel *c, bool is_stderr, const void *, size_t);
void (*write_eof)(SshChannel *c);
void (*initiate_close)(SshChannel *c, const char *err);
void (*unthrottle)(SshChannel *c, int bufsize);
void (*unthrottle)(SshChannel *c, size_t bufsize);
Conf *(*get_conf)(SshChannel *c);
void (*window_override_removed)(SshChannel *c);
void (*x11_sharing_handover)(SshChannel *c,

View File

@ -262,7 +262,8 @@ void ssh_free_pktout(PktOut *pkt)
*/
static void zombiechan_free(Channel *chan);
static int zombiechan_send(Channel *chan, bool is_stderr, const void *, int);
static size_t zombiechan_send(
Channel *chan, bool is_stderr, const void *, size_t);
static void zombiechan_set_input_wanted(Channel *chan, bool wanted);
static void zombiechan_do_nothing(Channel *chan);
static void zombiechan_open_failure(Channel *chan, const char *);
@ -318,8 +319,8 @@ static void zombiechan_open_failure(Channel *chan, const char *errtext)
assert(chan->vt == &zombiechan_channelvt);
}
static int zombiechan_send(Channel *chan, bool is_stderr,
const void *data, int length)
static size_t zombiechan_send(Channel *chan, bool is_stderr,
const void *data, size_t length)
{
assert(chan->vt == &zombiechan_channelvt);
return 0;

View File

@ -133,7 +133,8 @@ static void server_closing(Plug *plug, const char *error_msg, int error_code,
}
}
static void server_receive(Plug *plug, int urgent, const char *data, int len)
static void server_receive(
Plug *plug, int urgent, const char *data, size_t len)
{
server *srv = container_of(plug, server, plug);
@ -147,7 +148,7 @@ static void server_receive(Plug *plug, int urgent, const char *data, int len)
queue_idempotent_callback(&srv->bpp->ic_in_raw);
}
static void server_sent(Plug *plug, int bufsize)
static void server_sent(Plug *plug, size_t bufsize)
{
#ifdef FIXME
server *srv = container_of(plug, server, plug);
@ -333,7 +334,7 @@ static void server_bpp_output_raw_data_callback(void *vctx)
while (bufchain_size(&srv->out_raw) > 0) {
void *data;
int len, backlog;
size_t len, backlog;
bufchain_prefix(&srv->out_raw, &data, &len);

View File

@ -164,7 +164,7 @@ struct ssh_sharing_connstate {
int curr_packetlen;
unsigned char recvbuf[0x4010];
int recvlen;
size_t recvlen;
/*
* Assorted state we have to remember about this downstream, so
@ -1754,7 +1754,7 @@ static void share_got_pkt_from_downstream(struct ssh_sharing_connstate *cs,
(c) = (unsigned char)*data++; \
} while (0)
static void share_receive(Plug *plug, int urgent, const char *data, int len)
static void share_receive(Plug *plug, int urgent, const char *data, size_t len)
{
ssh_sharing_connstate *cs = container_of(
plug, ssh_sharing_connstate, plug);
@ -1830,7 +1830,7 @@ static void share_receive(Plug *plug, int urgent, const char *data, int len)
crFinishV;
}
static void share_sent(Plug *plug, int bufsize)
static void share_sent(Plug *plug, size_t bufsize)
{
/* ssh_sharing_connstate *cs = container_of(
plug, ssh_sharing_connstate, plug); */

View File

@ -29,7 +29,7 @@ struct ssh_verstring_state {
char prefix[PREFIX_MAXLEN];
char *impl_name;
char *vstring;
int vslen, vstrsize;
size_t vslen, vstrsize;
char *protoversion;
const char *softwareversion;
@ -249,7 +249,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
* If we didn't find it, consume data until we see a newline.
*/
while (1) {
int len;
size_t len;
void *data;
char *nl;
@ -281,7 +281,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
*/
s->i = 0;
do {
int len;
size_t len;
void *data;
char *nl;
@ -291,7 +291,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
len = nl - (char *)data + 1;
}
if (s->vslen + len >= s->vstrsize - 1) {
if (s->vslen >= s->vstrsize - 1 || len >= s->vstrsize - 1 - s->vslen) {
s->vstrsize = (s->vslen + len) * 5 / 4 + 32;
s->vstring = sresize(s->vstring, s->vstrsize, char);
}

View File

@ -182,7 +182,7 @@ struct Telnet {
bool echoing, editing;
bool activated;
int bufsize;
size_t bufsize;
bool in_synch;
int sb_opt, sb_len;
unsigned char *sb_buf;
@ -206,10 +206,9 @@ struct Telnet {
#define SB_DELTA 1024
static void c_write(Telnet *telnet, const void *buf, int len)
static void c_write(Telnet *telnet, const void *buf, size_t len)
{
int backlog;
backlog = seat_stdout(telnet->seat, buf, len);
size_t backlog = seat_stdout(telnet->seat, buf, len);
sk_set_frozen(telnet->s, backlog > TELNET_MAX_BACKLOG);
}
@ -506,7 +505,7 @@ static void process_subneg(Telnet *telnet)
}
}
static void do_telnet_read(Telnet *telnet, const char *buf, int len)
static void do_telnet_read(Telnet *telnet, const char *buf, size_t len)
{
strbuf *outbuf = strbuf_new();
@ -654,7 +653,8 @@ static void telnet_closing(Plug *plug, const char *error_msg, int error_code,
/* Otherwise, the remote side closed the connection normally. */
}
static void telnet_receive(Plug *plug, int urgent, const char *data, int len)
static void telnet_receive(
Plug *plug, int urgent, const char *data, size_t len)
{
Telnet *telnet = container_of(plug, Telnet, plug);
if (urgent)
@ -663,7 +663,7 @@ static void telnet_receive(Plug *plug, int urgent, const char *data, int len)
do_telnet_read(telnet, data, len);
}
static void telnet_sent(Plug *plug, int bufsize)
static void telnet_sent(Plug *plug, size_t bufsize)
{
Telnet *telnet = container_of(plug, Telnet, plug);
telnet->bufsize = bufsize;
@ -815,7 +815,7 @@ static void telnet_reconfig(Backend *be, Conf *conf)
/*
* Called to send data down the Telnet connection.
*/
static int telnet_send(Backend *be, const char *buf, int len)
static size_t telnet_send(Backend *be, const char *buf, size_t len)
{
Telnet *telnet = container_of(be, Telnet, backend);
unsigned char *p, *end;
@ -850,7 +850,7 @@ static int telnet_send(Backend *be, const char *buf, int len)
/*
* Called to query the current socket sendability status.
*/
static int telnet_sendbuffer(Backend *be)
static size_t telnet_sendbuffer(Backend *be)
{
Telnet *telnet = container_of(be, Telnet, backend);
return telnet->bufsize;
@ -1009,7 +1009,7 @@ static bool telnet_sendok(Backend *be)
return true;
}
static void telnet_unthrottle(Backend *be, int backlog)
static void telnet_unthrottle(Backend *be, size_t backlog)
{
Telnet *telnet = container_of(be, Telnet, backend);
sk_set_frozen(telnet->s, backlog > TELNET_MAX_BACKLOG);

View File

@ -2692,8 +2692,7 @@ static void term_print_setup(Terminal *term, char *printer)
static void term_print_flush(Terminal *term)
{
void *data;
int len;
int size;
size_t len, size;
while ((size = bufchain_size(&term->printer_buf)) > 5) {
bufchain_prefix(&term->printer_buf, &data, &len);
if (len > size-5)
@ -2705,7 +2704,7 @@ static void term_print_flush(Terminal *term)
static void term_print_finish(Terminal *term)
{
void *data;
int len, size;
size_t len, size;
char c;
if (!term->printing && !term->only_printing)
@ -2875,7 +2874,7 @@ static void term_out(Terminal *term)
unsigned long c;
int unget;
unsigned char localbuf[256], *chars;
int nchars = 0;
size_t nchars = 0;
unget = -1;
@ -6713,7 +6712,7 @@ static void term_added_data(Terminal *term)
}
}
int term_data(Terminal *term, bool is_stderr, const void *data, int len)
size_t term_data(Terminal *term, bool is_stderr, const void *data, size_t len)
{
bufchain_add(&term->inbuf, data, len);
term_added_data(term);
@ -6740,7 +6739,7 @@ int term_data(Terminal *term, bool is_stderr, const void *data, int len)
return 0;
}
static void term_data_untrusted(Terminal *term, const void *data, int len)
static void term_data_untrusted(Terminal *term, const void *data, size_t len)
{
sanitise_term_data(&term->inbuf, data, len);
term_added_data(term);

View File

@ -39,9 +39,9 @@ static const char *loop_init(Seat *, Backend **, LogContext *, Conf *,
static void null_free(Backend *);
static void loop_free(Backend *);
static void null_reconfig(Backend *, Conf *);
static int null_send(Backend *, const char *, int);
static int loop_send(Backend *, const char *, int);
static int null_sendbuffer(Backend *);
static size_t null_send(Backend *, const char *, size_t);
static size_t loop_send(Backend *, const char *, size_t);
static size_t null_sendbuffer(Backend *);
static void null_size(Backend *, int, int);
static void null_special(Backend *, SessionSpecialCode, int);
static const SessionSpecial *null_get_specials(Backend *);
@ -50,7 +50,7 @@ static int null_exitcode(Backend *);
static int null_sendok(Backend *);
static int null_ldisc(Backend *, int);
static void null_provide_ldisc(Backend *, Ldisc *);
static void null_unthrottle(Backend *, int);
static void null_unthrottle(Backend *, size_t);
static int null_cfg_info(Backend *);
const struct BackendVtable null_backend = {
@ -107,18 +107,18 @@ static void null_reconfig(Backend *be, Conf *conf) {
}
static int null_send(Backend *be, const char *buf, int len) {
static size_t null_send(Backend *be, const char *buf, size_t len) {
return 0;
}
static int loop_send(Backend *be, const char *buf, int len) {
static size_t loop_send(Backend *be, const char *buf, size_t len) {
struct loop_state *st = container_of(be, struct loop_state, backend);
return seat_output(st->seat, 0, buf, len);
}
static int null_sendbuffer(Backend *be) {
static size_t null_sendbuffer(Backend *be) {
return 0;
}
@ -151,7 +151,7 @@ static int null_sendok(Backend *be) {
return 1;
}
static void null_unthrottle(Backend *be, int backlog) {
static void null_unthrottle(Backend *be, size_t backlog) {
}

View File

@ -314,8 +314,8 @@ static char *gtk_seat_get_ttymode(Seat *seat, const char *mode)
return term_get_ttymode(inst->term, mode);
}
static int gtk_seat_output(Seat *seat, bool is_stderr,
const void *data, int len)
static size_t gtk_seat_output(Seat *seat, bool is_stderr,
const void *data, size_t len)
{
GtkFrontend *inst = container_of(seat, GtkFrontend, seat);
return term_data(inst->term, is_stderr, data, len);

View File

@ -490,7 +490,7 @@ static void console_close(FILE *outfp, int infd)
fclose(outfp); /* will automatically close infd too */
}
static void console_prompt_text(FILE *outfp, const char *data, int len)
static void console_prompt_text(FILE *outfp, const char *data, size_t len)
{
bufchain sanitised;
void *vdata;

View File

@ -163,7 +163,8 @@ static int fdsocket_try_send(FdSocket *fds)
while (bufchain_size(&fds->pending_output_data) > 0) {
void *data;
int len, ret;
size_t len;
ssize_t ret;
bufchain_prefix(&fds->pending_output_data, &data, &len);
ret = write(fds->outfd, data, len);
@ -198,7 +199,7 @@ static int fdsocket_try_send(FdSocket *fds)
return sent;
}
static int fdsocket_write(Socket *s, const void *data, int len)
static size_t fdsocket_write(Socket *s, const void *data, size_t len)
{
FdSocket *fds = container_of(s, FdSocket, sock);
@ -211,7 +212,7 @@ static int fdsocket_write(Socket *s, const void *data, int len)
return bufchain_size(&fds->pending_output_data);
}
static int fdsocket_write_oob(Socket *s, const void *data, int len)
static size_t fdsocket_write_oob(Socket *s, const void *data, size_t len)
{
/*
* oob data is treated as inband; nasty, but nothing really

View File

@ -69,7 +69,7 @@ struct NetSocket {
bool frozen; /* this causes readability notifications to be ignored */
bool localhost_only; /* for listening sockets */
char oobdata[1];
int sending_oob;
size_t sending_oob;
bool oobpending; /* is there OOB data available to read? */
bool oobinline;
enum { EOF_NO, EOF_PENDING, EOF_SENT } outgoingeof;
@ -500,8 +500,8 @@ static void sk_net_flush(Socket *s)
}
static void sk_net_close(Socket *s);
static int sk_net_write(Socket *s, const void *data, int len);
static int sk_net_write_oob(Socket *s, const void *data, int len);
static size_t sk_net_write(Socket *s, const void *data, size_t len);
static size_t sk_net_write_oob(Socket *s, const void *data, size_t len);
static void sk_net_write_eof(Socket *s);
static void sk_net_set_frozen(Socket *s, bool is_frozen);
static SocketPeerInfo *sk_net_peer_info(Socket *s);
@ -1112,7 +1112,8 @@ void try_send(NetSocket *s)
int nsent;
int err;
void *data;
int len, urgentflag;
size_t len;
int urgentflag;
if (s->sending_oob) {
urgentflag = MSG_OOB;
@ -1186,7 +1187,7 @@ void try_send(NetSocket *s)
uxsel_tell(s);
}
static int sk_net_write(Socket *sock, const void *buf, int len)
static size_t sk_net_write(Socket *sock, const void *buf, size_t len)
{
NetSocket *s = container_of(sock, NetSocket, sock);
@ -1212,7 +1213,7 @@ static int sk_net_write(Socket *sock, const void *buf, int len)
return bufchain_size(&s->output_data);
}
static int sk_net_write_oob(Socket *sock, const void *buf, int len)
static size_t sk_net_write_oob(Socket *sock, const void *buf, size_t len)
{
NetSocket *s = container_of(sock, NetSocket, sock);
@ -1451,7 +1452,7 @@ static void net_select_result(int fd, int event)
s->writable = true;
uxsel_tell(s);
} else {
int bufsize_before, bufsize_after;
size_t bufsize_before, bufsize_after;
s->writable = true;
bufsize_before = s->sending_oob + bufchain_size(&s->output_data);
try_send(s);

View File

@ -155,8 +155,8 @@ void chan_no_request_response(Channel *chan, bool success) {}
*/
static void x11_log(Plug *p, int type, SockAddr *addr, int port,
const char *error_msg, int error_code) {}
static void x11_receive(Plug *plug, int urgent, const char *data, int len) {}
static void x11_sent(Plug *plug, int bufsize) {}
static void x11_receive(Plug *plug, int urgent, const char *data, size_t len) {}
static void x11_sent(Plug *plug, size_t bufsize) {}
static void x11_closing(Plug *plug, const char *error_msg, int error_code,
bool calling_back)
{

View File

@ -325,12 +325,13 @@ void cleanup_termios(void)
bufchain stdout_data, stderr_data;
enum { EOF_NO, EOF_PENDING, EOF_SENT } outgoingeof;
int try_output(bool is_stderr)
size_t try_output(bool is_stderr)
{
bufchain *chain = (is_stderr ? &stderr_data : &stdout_data);
int fd = (is_stderr ? STDERR_FILENO : STDOUT_FILENO);
void *senddata;
int sendlen, ret;
size_t sendlen;
ssize_t ret;
if (bufchain_size(chain) > 0) {
bool prev_nonblock = nonblock(fd);
@ -354,7 +355,8 @@ int try_output(bool is_stderr)
return bufchain_size(&stdout_data) + bufchain_size(&stderr_data);
}
static int plink_output(Seat *seat, bool is_stderr, const void *data, int len)
static size_t plink_output(
Seat *seat, bool is_stderr, const void *data, size_t len)
{
if (is_stderr) {
bufchain_add(&stderr_data, data, len);

View File

@ -1310,7 +1310,8 @@ static void pty_free(Backend *be)
static void pty_try_write(Pty *pty)
{
void *data;
int len, ret;
size_t len;
ssize_t ret;
assert(pty->master_i >= 0);
@ -1348,7 +1349,7 @@ static void pty_try_write(Pty *pty)
/*
* Called to send data down the pty.
*/
static int pty_send(Backend *be, const char *buf, int len)
static size_t pty_send(Backend *be, const char *buf, size_t len)
{
Pty *pty = container_of(be, Pty, backend);
@ -1393,7 +1394,7 @@ static void pty_close(Pty *pty)
/*
* Called to query the current socket sendability status.
*/
static int pty_sendbuffer(Backend *be)
static size_t pty_sendbuffer(Backend *be)
{
/* Pty *pty = container_of(be, Pty, backend); */
return 0;
@ -1494,7 +1495,7 @@ static bool pty_sendok(Backend *be)
return true;
}
static void pty_unthrottle(Backend *be, int backlog)
static void pty_unthrottle(Backend *be, size_t backlog)
{
/* Pty *pty = container_of(be, Pty, backend); */
/* do nothing */

View File

@ -23,7 +23,7 @@ struct Serial {
LogContext *logctx;
int fd;
bool finished;
int inbufsize;
size_t inbufsize;
bufchain output_data;
Backend backend;
};
@ -423,7 +423,8 @@ static void serial_uxsel_setup(Serial *serial)
static void serial_try_write(Serial *serial)
{
void *data;
int len, ret;
size_t len;
ssize_t ret;
assert(serial->fd >= 0);
@ -450,7 +451,7 @@ static void serial_try_write(Serial *serial)
/*
* Called to send data down the serial connection.
*/
static int serial_send(Backend *be, const char *buf, int len)
static size_t serial_send(Backend *be, const char *buf, size_t len)
{
Serial *serial = container_of(be, Serial, backend);
@ -466,7 +467,7 @@ static int serial_send(Backend *be, const char *buf, int len)
/*
* Called to query the current sendability status.
*/
static int serial_sendbuffer(Backend *be)
static size_t serial_sendbuffer(Backend *be)
{
Serial *serial = container_of(be, Serial, backend);
return bufchain_size(&serial->output_data);
@ -519,7 +520,7 @@ static bool serial_sendok(Backend *be)
return true;
}
static void serial_unthrottle(Backend *be, int backlog)
static void serial_unthrottle(Backend *be, size_t backlog)
{
Serial *serial = container_of(be, Serial, backend);
serial->inbufsize = backlog;

25
utils.c
View File

@ -642,7 +642,7 @@ void bufchain_clear(bufchain *ch)
ch->buffersize = 0;
}
int bufchain_size(bufchain *ch)
size_t bufchain_size(bufchain *ch)
{
return ch->buffersize;
}
@ -655,7 +655,7 @@ void bufchain_set_callback_inner(
ch->ic = ic;
}
void bufchain_add(bufchain *ch, const void *data, int len)
void bufchain_add(bufchain *ch, const void *data, size_t len)
{
const char *buf = (const char *)data;
@ -665,14 +665,14 @@ void bufchain_add(bufchain *ch, const void *data, int len)
while (len > 0) {
if (ch->tail && ch->tail->bufend < ch->tail->bufmax) {
int copylen = min(len, ch->tail->bufmax - ch->tail->bufend);
size_t copylen = min(len, ch->tail->bufmax - ch->tail->bufend);
memcpy(ch->tail->bufend, buf, copylen);
buf += copylen;
len -= copylen;
ch->tail->bufend += copylen;
}
if (len > 0) {
int grainlen =
size_t grainlen =
max(sizeof(struct bufchain_granule) + len, BUFFER_MIN_GRANULE);
struct bufchain_granule *newbuf;
newbuf = smalloc(grainlen);
@ -692,7 +692,7 @@ void bufchain_add(bufchain *ch, const void *data, int len)
ch->queue_idempotent_callback(ch->ic);
}
void bufchain_consume(bufchain *ch, int len)
void bufchain_consume(bufchain *ch, size_t len)
{
struct bufchain_granule *tmp;
@ -714,13 +714,13 @@ void bufchain_consume(bufchain *ch, int len)
}
}
void bufchain_prefix(bufchain *ch, void **data, int *len)
void bufchain_prefix(bufchain *ch, void **data, size_t *len)
{
*len = ch->head->bufend - ch->head->bufpos;
*data = ch->head->bufpos;
}
void bufchain_fetch(bufchain *ch, void *data, int len)
void bufchain_fetch(bufchain *ch, void *data, size_t len)
{
struct bufchain_granule *tmp;
char *data_c = (char *)data;
@ -742,13 +742,13 @@ void bufchain_fetch(bufchain *ch, void *data, int len)
}
}
void bufchain_fetch_consume(bufchain *ch, void *data, int len)
void bufchain_fetch_consume(bufchain *ch, void *data, size_t len)
{
bufchain_fetch(ch, data, len);
bufchain_consume(ch, len);
}
bool bufchain_try_fetch_consume(bufchain *ch, void *data, int len)
bool bufchain_try_fetch_consume(bufchain *ch, void *data, size_t len)
{
if (ch->buffersize >= len) {
bufchain_fetch_consume(ch, data, len);
@ -758,7 +758,7 @@ bool bufchain_try_fetch_consume(bufchain *ch, void *data, int len)
}
}
int bufchain_fetch_consume_up_to(bufchain *ch, void *data, int len)
size_t bufchain_fetch_consume_up_to(bufchain *ch, void *data, size_t len)
{
if (len > ch->buffersize)
len = ch->buffersize;
@ -774,10 +774,9 @@ int bufchain_fetch_consume_up_to(bufchain *ch, void *data, int len)
* sequences.
*/
void sanitise_term_data(bufchain *out, const void *vdata, int len)
void sanitise_term_data(bufchain *out, const void *vdata, size_t len)
{
const char *data = (const char *)vdata;
int i;
/*
* FIXME: this method of sanitisation is ASCII-centric. It would
@ -786,7 +785,7 @@ void sanitise_term_data(bufchain *out, const void *vdata, int len)
* (not to mention knowing what character set it should interpret
* the data as).
*/
for (i = 0; i < len; i++) {
for (size_t i = 0; i < len; i++) {
if (data[i] == '\n')
bufchain_add(out, "\r\n", 2);
else if (data[i] >= ' ' && data[i] < 0x7F)

View File

@ -388,7 +388,7 @@ static void console_eventlog(LogPolicy *lp, const char *string)
console_logging_error(lp, string);
}
static void console_data_untrusted(HANDLE hout, const char *data, int len)
static void console_data_untrusted(HANDLE hout, const char *data, size_t len)
{
DWORD dummy;
bufchain sanitised;
@ -465,7 +465,7 @@ int console_get_userpass_input(prompts_t *p)
for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {
DWORD savemode, newmode;
int len;
size_t len;
prompt_t *pr = p->prompts[curr_prompt];
GetConsoleMode(hin, &savemode);
@ -486,7 +486,7 @@ int console_get_userpass_input(prompts_t *p)
if (!ReadFile(hin, pr->result + len, pr->resultsize - len - 1,
&ret, NULL) || ret == 0) {
len = -1;
len = (size_t)-1;
break;
}
len += ret;
@ -505,7 +505,7 @@ int console_get_userpass_input(prompts_t *p)
WriteFile(hout, "\r\n", 2, &dummy, NULL);
}
if (len < 0) {
if (len == (size_t)-1) {
return 0; /* failure due to read error */
}

View File

@ -320,7 +320,8 @@ bool win_seat_get_window_pixel_size(Seat *seat, int *x, int *y)
return true;
}
static int win_seat_output(Seat *seat, bool is_stderr, const void *, int);
static size_t win_seat_output(
Seat *seat, bool is_stderr, const void *, size_t);
static bool win_seat_eof(Seat *seat);
static int win_seat_get_userpass_input(
Seat *seat, prompts_t *p, bufchain *input);
@ -5784,8 +5785,8 @@ static void flip_full_screen()
}
}
static int win_seat_output(Seat *seat, bool is_stderr,
const void *data, int len)
static size_t win_seat_output(Seat *seat, bool is_stderr,
const void *data, size_t len)
{
return term_data(term, is_stderr, data, len);
}

View File

@ -348,12 +348,12 @@ static DWORD WINAPI handle_output_threadfunc(void *param)
static void handle_try_output(struct handle_output *ctx)
{
void *senddata;
int sendlen;
size_t sendlen;
if (!ctx->busy && bufchain_size(&ctx->queued_data)) {
bufchain_prefix(&ctx->queued_data, &senddata, &sendlen);
ctx->buffer = senddata;
ctx->len = sendlen;
ctx->len = min(sendlen, ~(DWORD)0);
SetEvent(ctx->ev_from_main);
ctx->busy = true;
} else if (!ctx->busy && bufchain_size(&ctx->queued_data) == 0 &&
@ -515,7 +515,7 @@ struct handle *handle_add_foreign_event(HANDLE event,
return h;
}
int handle_write(struct handle *h, const void *data, int len)
size_t handle_write(struct handle *h, const void *data, size_t len)
{
assert(h->type == HT_OUTPUT);
assert(h->u.o.outgoingeof == EOF_NO);
@ -702,13 +702,13 @@ void handle_got_event(HANDLE event)
}
}
void handle_unthrottle(struct handle *h, int backlog)
void handle_unthrottle(struct handle *h, size_t backlog)
{
assert(h->type == HT_INPUT);
handle_throttle(&h->u.i, backlog);
}
int handle_backlog(struct handle *h)
size_t handle_backlog(struct handle *h)
{
assert(h->type == HT_OUTPUT);
return bufchain_size(&h->u.o.queued_data);

View File

@ -45,7 +45,8 @@ typedef struct HandleSocket {
Socket sock;
} HandleSocket;
static int handle_gotdata(struct handle *h, const void *data, int len, int err)
static size_t handle_gotdata(
struct handle *h, const void *data, size_t len, int err)
{
HandleSocket *hs = (HandleSocket *)handle_get_privdata(h);
@ -79,7 +80,8 @@ static int handle_gotdata(struct handle *h, const void *data, int len, int err)
}
}
static int handle_stderr(struct handle *h, const void *data, int len, int err)
static size_t handle_stderr(
struct handle *h, const void *data, size_t len, int err)
{
HandleSocket *hs = (HandleSocket *)handle_get_privdata(h);
@ -89,7 +91,7 @@ static int handle_stderr(struct handle *h, const void *data, int len, int err)
return 0;
}
static void handle_sentdata(struct handle *h, int new_backlog, int err)
static void handle_sentdata(struct handle *h, size_t new_backlog, int err)
{
HandleSocket *hs = (HandleSocket *)handle_get_privdata(h);
@ -130,14 +132,14 @@ static void sk_handle_close(Socket *s)
sfree(hs);
}
static int sk_handle_write(Socket *s, const void *data, int len)
static size_t sk_handle_write(Socket *s, const void *data, size_t len)
{
HandleSocket *hs = container_of(s, HandleSocket, sock);
return handle_write(hs->send_h, data, len);
}
static int sk_handle_write_oob(Socket *s, const void *data, int len)
static size_t sk_handle_write_oob(Socket *s, const void *data, size_t len)
{
/*
* oob data is treated as inband; nasty, but nothing really
@ -163,7 +165,7 @@ static void handle_socket_unfreeze(void *hsv)
{
HandleSocket *hs = (HandleSocket *)hsv;
void *data;
int len;
size_t len;
/*
* If we've been put into a state other than THAWING since the

View File

@ -60,7 +60,7 @@ struct NetSocket {
* notification while we were frozen */
bool localhost_only; /* for listening sockets */
char oobdata[1];
int sending_oob;
size_t sending_oob;
bool oobinline, nodelay, keepalive, privport;
enum { EOF_NO, EOF_PENDING, EOF_SENT } outgoingeof;
SockAddr *addr;
@ -832,8 +832,8 @@ static void sk_net_flush(Socket *s)
}
static void sk_net_close(Socket *s);
static int sk_net_write(Socket *s, const void *data, int len);
static int sk_net_write_oob(Socket *s, const void *data, int len);
static size_t sk_net_write(Socket *s, const void *data, size_t len);
static size_t sk_net_write_oob(Socket *s, const void *data, size_t len);
static void sk_net_write_eof(Socket *s);
static void sk_net_set_frozen(Socket *s, bool is_frozen);
static const char *sk_net_socket_error(Socket *s);
@ -1378,7 +1378,8 @@ void try_send(NetSocket *s)
int nsent;
DWORD err;
void *data;
int len, urgentflag;
size_t len;
int urgentflag;
if (s->sending_oob) {
urgentflag = MSG_OOB;
@ -1388,6 +1389,7 @@ void try_send(NetSocket *s)
urgentflag = 0;
bufchain_prefix(&s->output_data, &data, &len);
}
len = min(len, INT_MAX); /* WinSock send() takes an int */
nsent = p_send(s->s, data, len, urgentflag);
noise_ultralight(NOISE_SOURCE_IOLEN, nsent);
if (nsent <= 0) {
@ -1443,7 +1445,7 @@ void try_send(NetSocket *s)
}
}
static int sk_net_write(Socket *sock, const void *buf, int len)
static size_t sk_net_write(Socket *sock, const void *buf, size_t len)
{
NetSocket *s = container_of(sock, NetSocket, sock);
@ -1463,7 +1465,7 @@ static int sk_net_write(Socket *sock, const void *buf, int len)
return bufchain_size(&s->output_data);
}
static int sk_net_write_oob(Socket *sock, const void *buf, int len)
static size_t sk_net_write_oob(Socket *sock, const void *buf, size_t len)
{
NetSocket *s = container_of(sock, NetSocket, sock);

View File

@ -61,7 +61,8 @@ static void plink_echoedit_update(Seat *seat, bool echo, bool edit)
SetConsoleMode(inhandle, mode);
}
static int plink_output(Seat *seat, bool is_stderr, const void *data, int len)
static size_t plink_output(
Seat *seat, bool is_stderr, const void *data, size_t len)
{
if (is_stderr) {
handle_write(stderr_handle, data, len);
@ -205,7 +206,7 @@ char *do_select(SOCKET skt, bool startup)
return NULL;
}
int stdin_gotdata(struct handle *h, const void *data, int len, int err)
size_t stdin_gotdata(struct handle *h, const void *data, size_t len, int err)
{
if (err) {
char buf[4096];
@ -217,6 +218,7 @@ int stdin_gotdata(struct handle *h, const void *data, int len, int err)
fprintf(stderr, "Unable to read from standard input: %s\n", buf);
cleanup_exit(0);
}
noise_ultralight(NOISE_SOURCE_IOLEN, len);
if (backend_connected(backend)) {
if (len > 0) {
@ -229,7 +231,7 @@ int stdin_gotdata(struct handle *h, const void *data, int len, int err)
return 0;
}
void stdouterr_sent(struct handle *h, int new_backlog, int err)
void stdouterr_sent(struct handle *h, size_t new_backlog, int err)
{
if (err) {
char buf[4096];

View File

@ -40,8 +40,8 @@ static void serial_terminate(Serial *serial)
}
}
static int serial_gotdata(
struct handle *h, const void *data, int len, int err)
static size_t serial_gotdata(
struct handle *h, const void *data, size_t len, int err)
{
Serial *serial = (Serial *)handle_get_privdata(h);
if (err || len == 0) {
@ -73,7 +73,7 @@ static int serial_gotdata(
}
}
static void serial_sentdata(struct handle *h, int new_backlog, int err)
static void serial_sentdata(struct handle *h, size_t new_backlog, int err)
{
Serial *serial = (Serial *)handle_get_privdata(h);
if (err) {
@ -295,7 +295,7 @@ static void serial_reconfig(Backend *be, Conf *conf)
/*
* Called to send data down the serial connection.
*/
static int serial_send(Backend *be, const char *buf, int len)
static size_t serial_send(Backend *be, const char *buf, size_t len)
{
Serial *serial = container_of(be, Serial, backend);
@ -309,7 +309,7 @@ static int serial_send(Backend *be, const char *buf, int len)
/*
* Called to query the current sendability status.
*/
static int serial_sendbuffer(Backend *be)
static size_t serial_sendbuffer(Backend *be)
{
Serial *serial = container_of(be, Serial, backend);
return serial->bufsize;
@ -386,7 +386,7 @@ static bool serial_sendok(Backend *be)
return true;
}
static void serial_unthrottle(Backend *be, int backlog)
static void serial_unthrottle(Backend *be, size_t backlog)
{
Serial *serial = container_of(be, Serial, backend);
if (serial->in)

View File

@ -603,21 +603,21 @@ void init_ucs(Conf *, struct unicode_data *);
#define HANDLE_FLAG_IGNOREEOF 2
#define HANDLE_FLAG_UNITBUFFER 4
struct handle;
typedef int (*handle_inputfn_t)(
struct handle *h, const void *data, int len, int err);
typedef size_t (*handle_inputfn_t)(
struct handle *h, const void *data, size_t len, int err);
typedef void (*handle_outputfn_t)(
struct handle *h, int new_backlog, int err);
struct handle *h, size_t new_backlog, int err);
struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata,
void *privdata, int flags);
struct handle *handle_output_new(HANDLE handle, handle_outputfn_t sentdata,
void *privdata, int flags);
int handle_write(struct handle *h, const void *data, int len);
size_t handle_write(struct handle *h, const void *data, size_t len);
void handle_write_eof(struct handle *h);
HANDLE *handle_get_events(int *nevents);
void handle_free(struct handle *h);
void handle_got_event(HANDLE event);
void handle_unthrottle(struct handle *h, int backlog);
int handle_backlog(struct handle *h);
void handle_unthrottle(struct handle *h, size_t backlog);
size_t handle_backlog(struct handle *h);
void *handle_get_privdata(struct handle *h);
struct handle *handle_add_foreign_event(HANDLE event,
void (*callback)(void *), void *ctx);

View File

@ -726,7 +726,7 @@ static void x11_closing(Plug *plug, const char *error_msg, int error_code,
}
}
static void x11_receive(Plug *plug, int urgent, const char *data, int len)
static void x11_receive(Plug *plug, int urgent, const char *data, size_t len)
{
struct X11Connection *xconn = container_of(
plug, struct X11Connection, plug);
@ -735,7 +735,7 @@ static void x11_receive(Plug *plug, int urgent, const char *data, int len)
sshfwd_write(xconn->c, data, len);
}
static void x11_sent(Plug *plug, int bufsize)
static void x11_sent(Plug *plug, size_t bufsize)
{
struct X11Connection *xconn = container_of(
plug, struct X11Connection, plug);
@ -770,7 +770,8 @@ static const PlugVtable X11Connection_plugvt = {
};
static void x11_chan_free(Channel *chan);
static int x11_send(Channel *chan, bool is_stderr, const void *vdata, int len);
static size_t x11_send(
Channel *chan, bool is_stderr, const void *vdata, size_t len);
static void x11_send_eof(Channel *chan);
static void x11_set_input_wanted(Channel *chan, bool wanted);
static char *x11_log_close_msg(Channel *chan);
@ -918,7 +919,8 @@ static bool x11_parse_ip(const char *addr_string, unsigned long *ip)
/*
* Called to send data down the raw connection.
*/
static int x11_send(Channel *chan, bool is_stderr, const void *vdata, int len)
static size_t x11_send(
Channel *chan, bool is_stderr, const void *vdata, size_t len)
{
assert(chan->vt == &X11Connection_channelvt);
X11Connection *xconn = container_of(chan, X11Connection, chan);