# HG changeset patch # User Francois Perrad # Date 1503175193 -7200 # Node ID 58a74cb829b822a869fa427daa0c5956a467aba4 # Parent 06d52bcb8094a4a3f2e2ed45c1605b9ca1fbe01f Pointer parameter could be declared as pointing to const (callback) diff -r 06d52bcb8094 -r 58a74cb829b8 channel.h --- a/channel.h Sat Aug 19 17:16:13 2017 +0200 +++ b/channel.h Sat Aug 19 22:39:53 2017 +0200 @@ -84,7 +84,7 @@ int flushing; /* Used by client chansession to handle ~ escaping, NULL ignored otherwise */ - void (*read_mangler)(struct Channel*, unsigned char* bytes, int *len); + void (*read_mangler)(const struct Channel*, const unsigned char* bytes, int *len); const struct ChanType* type; @@ -98,7 +98,7 @@ int (*inithandler)(struct Channel*); int (*check_close)(struct Channel*); void (*reqhandler)(struct Channel*); - void (*closehandler)(struct Channel*); + void (*closehandler)(const struct Channel*); }; /* Callback for connect_remote */ diff -r 06d52bcb8094 -r 58a74cb829b8 cli-chansession.c --- a/cli-chansession.c Sat Aug 19 17:16:13 2017 +0200 +++ b/cli-chansession.c Sat Aug 19 22:39:53 2017 +0200 @@ -35,12 +35,12 @@ #include "chansession.h" #include "agentfwd.h" -static void cli_closechansess(struct Channel *channel); +static void cli_closechansess(const struct Channel *channel); static int cli_initchansess(struct Channel *channel); static void cli_chansessreq(struct Channel *channel); static void send_chansess_pty_req(const struct Channel *channel); static void send_chansess_shell_req(const struct Channel *channel); -static void cli_escape_handler(struct Channel *channel, unsigned char* buf, int *len); +static void cli_escape_handler(const struct Channel *channel, const unsigned char* buf, int *len); static int cli_init_netcat(struct Channel *channel); static void cli_tty_setup(void); @@ -83,7 +83,7 @@ /* If the main session goes, we close it up */ -static void cli_closechansess(struct Channel *UNUSED(channel)) { +static void cli_closechansess(const struct Channel *UNUSED(channel)) { cli_tty_cleanup(); /* Restore tty modes etc */ /* This channel hasn't gone yet, so we have > 1 */ @@ -452,7 +452,7 @@ } static -void cli_escape_handler(struct Channel* UNUSED(channel), unsigned char* buf, int *len) { +void cli_escape_handler(const struct Channel* UNUSED(channel), const unsigned char* buf, int *len) { char c; int skip_char = 0; diff -r 06d52bcb8094 -r 58a74cb829b8 cli-main.c --- a/cli-main.c Sat Aug 19 17:16:13 2017 +0200 +++ b/cli-main.c Sat Aug 19 22:39:53 2017 +0200 @@ -142,7 +142,7 @@ fflush(stderr); } -static void exec_proxy_cmd(void *user_data_cmd) { +static void exec_proxy_cmd(const void *user_data_cmd) { const char *cmd = user_data_cmd; char *usershell; diff -r 06d52bcb8094 -r 58a74cb829b8 dbutil.c --- a/dbutil.c Sat Aug 19 17:16:13 2017 +0200 +++ b/dbutil.c Sat Aug 19 22:39:53 2017 +0200 @@ -241,7 +241,7 @@ * it will be run after the child has fork()ed, and is passed exec_data. * If ret_errfd == NULL then stderr will not be captured. * ret_pid can be passed as NULL to discard the pid. */ -int spawn_command(void(*exec_fn)(void *user_data), void *exec_data, +int spawn_command(void(*exec_fn)(const void *user_data), const void *exec_data, int *ret_writefd, int *ret_readfd, int *ret_errfd, pid_t *ret_pid) { int infds[2]; int outfds[2]; diff -r 06d52bcb8094 -r 58a74cb829b8 dbutil.h --- a/dbutil.h Sat Aug 19 17:16:13 2017 +0200 +++ b/dbutil.h Sat Aug 19 22:39:53 2017 +0200 @@ -56,7 +56,7 @@ char * stripcontrol(const char * text); -int spawn_command(void(*exec_fn)(void *user_data), void *exec_data, +int spawn_command(void(*exec_fn)(const void *user_data), const void *exec_data, int *writefd, int *readfd, int *errfd, pid_t *pid); void run_shell_command(const char* cmd, unsigned int maxfd, char* usershell); #ifdef ENABLE_CONNECT_UNIX diff -r 06d52bcb8094 -r 58a74cb829b8 listener.c --- a/listener.c Sat Aug 19 17:16:13 2017 +0200 +++ b/listener.c Sat Aug 19 22:39:53 2017 +0200 @@ -78,8 +78,8 @@ * cleanup(void* typedata) happens when cleaning up */ struct Listener* new_listener(const int socks[], unsigned int nsocks, int type, void* typedata, - void (*acceptor)(struct Listener* listener, int sock), - void (*cleanup)(struct Listener*)) { + void (*acceptor)(const struct Listener* listener, int sock), + void (*cleanup)(const struct Listener*)) { unsigned int i, j; struct Listener *newlisten = NULL; @@ -132,8 +132,8 @@ /* Return the first listener which matches the type-specific comparison * function. Particularly needed for global requests, like tcp */ -struct Listener * get_listener(int type, void* typedata, - int (*match)(void*, void*)) { +struct Listener * get_listener(int type, const void* typedata, + int (*match)(const void*, const void*)) { unsigned int i; struct Listener* listener; diff -r 06d52bcb8094 -r 58a74cb829b8 listener.h --- a/listener.h Sat Aug 19 17:16:13 2017 +0200 +++ b/listener.h Sat Aug 19 22:39:53 2017 +0200 @@ -35,8 +35,8 @@ int index; /* index in the array of listeners */ - void (*acceptor)(struct Listener*, int sock); - void (*cleanup)(struct Listener*); + void (*acceptor)(const struct Listener*, int sock); + void (*cleanup)(const struct Listener*); int type; /* CHANNEL_ID_X11, CHANNEL_ID_AGENT, CHANNEL_ID_TCPDIRECT (for clients), @@ -52,11 +52,11 @@ struct Listener* new_listener(const int socks[], unsigned int nsocks, int type, void* typedata, - void (*acceptor)(struct Listener* listener, int sock), - void (*cleanup)(struct Listener*)); + void (*acceptor)(const struct Listener* listener, int sock), + void (*cleanup)(const struct Listener*)); -struct Listener * get_listener(int type, void* typedata, - int (*match)(void*, void*)); +struct Listener * get_listener(int type, const void* typedata, + int (*match)(const void*, const void*)); void remove_listener(struct Listener* listener); diff -r 06d52bcb8094 -r 58a74cb829b8 svr-agentfwd.c --- a/svr-agentfwd.c Sat Aug 19 17:16:13 2017 +0200 +++ b/svr-agentfwd.c Sat Aug 19 22:39:53 2017 +0200 @@ -45,7 +45,7 @@ static int send_msg_channel_open_agent(int fd); static int bindagent(int fd, struct ChanSess * chansess); -static void agentaccept(struct Listener * listener, int sock); +static void agentaccept(const struct Listener * listener, int sock); /* Handles client requests to start agent forwarding, sets up listening socket. * Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ @@ -100,7 +100,7 @@ /* accepts a connection on the forwarded socket and opens a new channel for it * back to the client */ /* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ -static void agentaccept(struct Listener *UNUSED(listener), int sock) { +static void agentaccept(const struct Listener *UNUSED(listener), int sock) { int fd; diff -r 06d52bcb8094 -r 58a74cb829b8 svr-chansession.c --- a/svr-chansession.c Sat Aug 19 17:16:13 2017 +0200 +++ b/svr-chansession.c Sat Aug 19 22:39:53 2017 +0200 @@ -47,10 +47,10 @@ static int noptycommand(struct Channel *channel, struct ChanSess *chansess); static int ptycommand(struct Channel *channel, struct ChanSess *chansess); static int sessionwinchange(const struct ChanSess *chansess); -static void execchild(void *user_data_chansess); +static void execchild(const void *user_data_chansess); static void addchildpid(struct ChanSess *chansess, pid_t pid); static void sesssigchild_handler(int val); -static void closechansess(struct Channel *channel); +static void closechansess(const struct Channel *channel); static int newchansess(struct Channel *channel); static void chansessionrequest(struct Channel *channel); static int sesscheckclose(const struct Channel *channel); @@ -281,7 +281,7 @@ } /* clean a session channel */ -static void closechansess(struct Channel *channel) { +static void closechansess(const struct Channel *channel) { struct ChanSess *chansess; unsigned int i; @@ -898,7 +898,7 @@ /* Clean up, drop to user privileges, set up the environment and execute * the command/shell. This function does not return. */ -static void execchild(void *user_data) { +static void execchild(const void *user_data) { struct ChanSess *chansess = user_data; char *usershell = NULL; diff -r 06d52bcb8094 -r 58a74cb829b8 svr-tcpfwd.c --- a/svr-tcpfwd.c Sat Aug 19 17:16:13 2017 +0200 +++ b/svr-tcpfwd.c Sat Aug 19 22:39:53 2017 +0200 @@ -107,7 +107,7 @@ TRACE(("leave recv_msg_global_request")) } -static int matchtcp(void* typedata1, void* typedata2) { +static int matchtcp(const void* typedata1, const void* typedata2) { const struct TCPListener *info1 = (struct TCPListener*)typedata1; const struct TCPListener *info2 = (struct TCPListener*)typedata2; diff -r 06d52bcb8094 -r 58a74cb829b8 svr-x11fwd.c --- a/svr-x11fwd.c Sat Aug 19 17:16:13 2017 +0200 +++ b/svr-x11fwd.c Sat Aug 19 22:39:53 2017 +0200 @@ -38,7 +38,7 @@ #define X11BASEPORT 6000 #define X11BINDBASE 6010 -static void x11accept(struct Listener* listener, int sock); +static void x11accept(const struct Listener* listener, int sock); static int bindport(int fd); static int send_msg_channel_open_x11(int fd, const struct sockaddr_in* addr); @@ -126,7 +126,7 @@ /* accepts a new X11 socket */ /* returns DROPBEAR_FAILURE or DROPBEAR_SUCCESS */ -static void x11accept(struct Listener* listener, int sock) { +static void x11accept(const struct Listener* listener, int sock) { int fd; struct sockaddr_in addr; diff -r 06d52bcb8094 -r 58a74cb829b8 tcp-accept.c --- a/tcp-accept.c Sat Aug 19 17:16:13 2017 +0200 +++ b/tcp-accept.c Sat Aug 19 22:39:53 2017 +0200 @@ -35,7 +35,7 @@ #if DROPBEAR_TCP_ACCEPT -static void cleanup_tcp(struct Listener *listener) { +static void cleanup_tcp(const struct Listener *listener) { struct TCPListener *tcpinfo = (struct TCPListener*)(listener->typedata); @@ -52,7 +52,7 @@ return 0; } -static void tcp_acceptor(struct Listener *listener, int sock) { +static void tcp_acceptor(const struct Listener *listener, int sock) { int fd; struct sockaddr_storage sa;