summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois Perrad <francois.perrad@gadz.org>2017-08-19 22:39:53 +0200
committerFrancois Perrad <francois.perrad@gadz.org>2017-08-19 22:39:53 +0200
commit2d3dbea54538277663f55515cac3d27ce16f0559 (patch)
tree210cd9ae566803253d96d24fc4fe9be1013c42f6
parent63300b49f30b3d63a551d4d568ae95fea24035ba (diff)
downloaddropbear-2d3dbea54538277663f55515cac3d27ce16f0559.tar.gz
Pointer parameter could be declared as pointing to const (callback)
-rw-r--r--channel.h4
-rw-r--r--cli-chansession.c8
-rw-r--r--cli-main.c2
-rw-r--r--dbutil.c2
-rw-r--r--dbutil.h2
-rw-r--r--listener.c8
-rw-r--r--listener.h12
-rw-r--r--svr-agentfwd.c4
-rw-r--r--svr-chansession.c8
-rw-r--r--svr-tcpfwd.c2
-rw-r--r--svr-x11fwd.c4
-rw-r--r--tcp-accept.c4
12 files changed, 30 insertions, 30 deletions
diff --git a/channel.h b/channel.h
index 08723e2..8736fbe 100644
--- a/channel.h
+++ b/channel.h
@@ -84,7 +84,7 @@ struct Channel {
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 @@ struct ChanType {
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 --git a/cli-chansession.c b/cli-chansession.c
index d190b20..ded9eac 100644
--- a/cli-chansession.c
+++ b/cli-chansession.c
@@ -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 @@ out:
/* 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 @@ do_escape(unsigned char c) {
}
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 --git a/cli-main.c b/cli-main.c
index 121da22..57a07cc 100644
--- a/cli-main.c
+++ b/cli-main.c
@@ -142,7 +142,7 @@ static void cli_dropbear_log(int priority,
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 --git a/dbutil.c b/dbutil.c
index 830e8d2..4467162 100644
--- a/dbutil.c
+++ b/dbutil.c
@@ -241,7 +241,7 @@ int connect_unix(const char* path) {
* 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 --git a/dbutil.h b/dbutil.h
index d83b20a..fe82272 100644
--- a/dbutil.h
+++ b/dbutil.h
@@ -56,7 +56,7 @@ extern int debug_trace;
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 --git a/listener.c b/listener.c
index c688005..9cccefc 100644
--- a/listener.c
+++ b/listener.c
@@ -78,8 +78,8 @@ void handle_listeners(const fd_set * readfds) {
* 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 @@ struct Listener* new_listener(const int socks[], unsigned int nsocks,
/* 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 --git a/listener.h b/listener.h
index e1a620b..4a7f5ff 100644
--- a/listener.h
+++ b/listener.h
@@ -35,8 +35,8 @@ struct Listener {
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 @@ void set_listener_fds(fd_set * readfds);
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 --git a/svr-agentfwd.c b/svr-agentfwd.c
index 5686aea..6289b87 100644
--- a/svr-agentfwd.c
+++ b/svr-agentfwd.c
@@ -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 @@ fail:
/* 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 --git a/svr-chansession.c b/svr-chansession.c
index ff94cf2..0e34350 100644
--- a/svr-chansession.c
+++ b/svr-chansession.c
@@ -47,10 +47,10 @@ static int sessionsignal(const struct ChanSess *chansess);
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 @@ chansess_login_alloc(const struct ChanSess *chansess) {
}
/* 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 @@ static void addchildpid(struct ChanSess *chansess, pid_t pid) {
/* 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 --git a/svr-tcpfwd.c b/svr-tcpfwd.c
index 207587c..faf372e 100644
--- a/svr-tcpfwd.c
+++ b/svr-tcpfwd.c
@@ -107,7 +107,7 @@ out:
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 --git a/svr-x11fwd.c b/svr-x11fwd.c
index 2aa57ef..6301aa5 100644
--- a/svr-x11fwd.c
+++ b/svr-x11fwd.c
@@ -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 @@ fail:
/* 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 --git a/tcp-accept.c b/tcp-accept.c
index 82f4a86..18cd8c6 100644
--- a/tcp-accept.c
+++ b/tcp-accept.c
@@ -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 @@ int tcp_prio_inithandler(struct Channel* channel)
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;