Skip to content
Snippets Groups Projects
Commit 89e64c63 authored by Francois Perrad's avatar Francois Perrad
Browse files

Pointer parameter could be declared as pointing to const

parent 468656b4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -40,8 +40,8 @@
/* client functions */
void cli_load_agent_keys(m_list * ret_list);
void agent_buf_sign(buffer *sigblob, sign_key *key,
buffer *data_buf);
void cli_setup_agent(struct Channel *channel);
const buffer *data_buf);
void cli_setup_agent(const struct Channel *channel);
 
#ifdef __hpux
#define seteuid(a) setresuid(-1, (a), -1)
Loading
Loading
@@ -56,7 +56,7 @@ extern const struct ChanType cli_chan_agent;
 
int svr_agentreq(struct ChanSess * chansess);
void svr_agentcleanup(struct ChanSess * chansess);
void svr_agentset(struct ChanSess *chansess);
void svr_agentset(const struct ChanSess *chansess);
 
#endif /* DROPBEAR_SVR_AGENTFWD */
 
Loading
Loading
Loading
Loading
@@ -112,8 +112,8 @@ struct dropbear_kex {
const struct ltc_hash_descriptor *hash_desc;
};
 
int have_algo(char* algo, size_t algolen, algo_type algos[]);
void buf_put_algolist(buffer * buf, algo_type localalgos[]);
int have_algo(const char* algo, size_t algolen, const algo_type algos[]);
void buf_put_algolist(buffer * buf, const algo_type localalgos[]);
 
enum kexguess2_used {
KEXGUESS2_LOOK,
Loading
Loading
@@ -131,7 +131,7 @@ algo_type * buf_match_algo(buffer* buf, algo_type localalgos[],
#if DROPBEAR_USER_ALGO_LIST
int check_user_algos(const char* user_algo_list, algo_type * algos,
const char *algo_desc);
char * algolist_string(algo_type algos[]);
char * algolist_string(const algo_type algos[]);
#endif
 
enum {
Loading
Loading
Loading
Loading
@@ -36,7 +36,7 @@ void cli_authinitialise(void);
void recv_msg_userauth_request(void);
void send_msg_userauth_failure(int partial, int incrfail);
void send_msg_userauth_success(void);
void send_msg_userauth_banner(buffer *msg);
void send_msg_userauth_banner(const buffer *msg);
void svr_auth_password(void);
void svr_auth_pubkey(void);
void svr_auth_pam(void);
Loading
Loading
@@ -74,7 +74,7 @@ void cli_pubkeyfail(void);
void cli_auth_password(void);
int cli_auth_pubkey(void);
void cli_auth_interactive(void);
char* getpass_or_cancel(char* prompt);
char* getpass_or_cancel(const char* prompt);
void cli_auth_pubkey_cleanup(void);
 
 
Loading
Loading
Loading
Loading
@@ -67,7 +67,7 @@ void buf_free(buffer* buf) {
}
 
/* overwrite the contents of the buffer to clear it */
void buf_burn(buffer* buf) {
void buf_burn(const buffer* buf) {
m_burn(buf->data, buf->size);
 
Loading
Loading
@@ -91,7 +91,7 @@ buffer* buf_resize(buffer *buf, unsigned int newsize) {
 
/* Create a copy of buf, allocating required memory etc. */
/* The new buffer is sized the same as the length of the source buffer. */
buffer* buf_newcopy(buffer* buf) {
buffer* buf_newcopy(const buffer* buf) {
buffer* ret;
 
Loading
Loading
@@ -184,7 +184,7 @@ void buf_putbyte(buffer* buf, unsigned char val) {
 
/* returns an in-place pointer to the buffer, checking that
* the next len bytes from that position can be used */
unsigned char* buf_getptr(buffer* buf, unsigned int len) {
unsigned char* buf_getptr(const buffer* buf, unsigned int len) {
 
if (len > BUF_MAX_INCR || buf->pos + len > buf->len) {
dropbear_exit("Bad buf_getptr");
Loading
Loading
@@ -194,7 +194,7 @@ unsigned char* buf_getptr(buffer* buf, unsigned int len) {
 
/* like buf_getptr, but checks against total size, not used length.
* This allows writing past the used length, but not past the size */
unsigned char* buf_getwriteptr(buffer* buf, unsigned int len) {
unsigned char* buf_getwriteptr(const buffer* buf, unsigned int len) {
 
if (len > BUF_MAX_INCR || buf->pos + len > buf->size) {
dropbear_exit("Bad buf_getwriteptr");
Loading
Loading
Loading
Loading
@@ -44,8 +44,8 @@ buffer * buf_new(unsigned int size);
/* Possibly returns a new buffer*, like realloc() */
buffer * buf_resize(buffer *buf, unsigned int newsize);
void buf_free(buffer* buf);
void buf_burn(buffer* buf);
buffer* buf_newcopy(buffer* buf);
void buf_burn(const buffer* buf);
buffer* buf_newcopy(const buffer* buf);
void buf_setlen(buffer* buf, unsigned int len);
void buf_incrlen(buffer* buf, unsigned int incr);
void buf_setpos(buffer* buf, unsigned int pos);
Loading
Loading
@@ -54,8 +54,8 @@ void buf_incrwritepos(buffer* buf, unsigned int incr);
unsigned char buf_getbyte(buffer* buf);
unsigned char buf_getbool(buffer* buf);
void buf_putbyte(buffer* buf, unsigned char val);
unsigned char* buf_getptr(buffer* buf, unsigned int len);
unsigned char* buf_getwriteptr(buffer* buf, unsigned int len);
unsigned char* buf_getptr(const buffer* buf, unsigned int len);
unsigned char* buf_getwriteptr(const buffer* buf, unsigned int len);
char* buf_getstring(buffer* buf, unsigned int *retlen);
buffer * buf_getstringbuf(buffer *buf);
void buf_eatstring(buffer *buf);
Loading
Loading
Loading
Loading
@@ -107,7 +107,7 @@ void channel_connect_done(int result, int sock, void* user_data, const char* err
void chaninitialise(const struct ChanType *chantypes[]);
void chancleanup(void);
void setchannelfds(fd_set *readfds, fd_set *writefds, int allow_reads);
void channelio(fd_set *readfd, fd_set *writefd);
void channelio(const fd_set *readfd, const fd_set *writefd);
struct Channel* getchannel(void);
/* Returns an arbitrary channel that is in a ready state - not
being initialised and no EOF in either direction. NULL if none. */
Loading
Loading
@@ -115,8 +115,8 @@ struct Channel* get_any_ready_channel(void);
 
void recv_msg_channel_open(void);
void recv_msg_channel_request(void);
void send_msg_channel_failure(struct Channel *channel);
void send_msg_channel_success(struct Channel *channel);
void send_msg_channel_failure(const struct Channel *channel);
void send_msg_channel_success(const struct Channel *channel);
void recv_msg_channel_data(void);
void recv_msg_channel_extended_data(void);
void recv_msg_channel_window_adjust(void);
Loading
Loading
@@ -135,7 +135,7 @@ int send_msg_channel_open_init(int fd, const struct ChanType *type);
void recv_msg_channel_open_confirmation(void);
void recv_msg_channel_open_failure(void);
#endif
void start_send_channel_request(struct Channel *channel, char *type);
void start_send_channel_request(const struct Channel *channel, const char *type);
 
void send_msg_request_success(void);
void send_msg_request_failure(void);
Loading
Loading
Loading
Loading
@@ -56,19 +56,19 @@ void cbuf_free(circbuffer * cbuf) {
m_free(cbuf);
}
 
unsigned int cbuf_getused(circbuffer * cbuf) {
unsigned int cbuf_getused(const circbuffer * cbuf) {
 
return cbuf->used;
 
}
 
unsigned int cbuf_getavail(circbuffer * cbuf) {
unsigned int cbuf_getavail(const circbuffer * cbuf) {
 
return cbuf->size - cbuf->used;
 
}
 
unsigned int cbuf_writelen(circbuffer *cbuf) {
unsigned int cbuf_writelen(const circbuffer *cbuf) {
 
dropbear_assert(cbuf->used <= cbuf->size);
dropbear_assert(((2*cbuf->size)+cbuf->writepos-cbuf->readpos)%cbuf->size == cbuf->used%cbuf->size);
Loading
Loading
@@ -86,7 +86,7 @@ unsigned int cbuf_writelen(circbuffer *cbuf) {
return cbuf->size - cbuf->writepos;
}
 
void cbuf_readptrs(circbuffer *cbuf,
void cbuf_readptrs(const circbuffer *cbuf,
unsigned char **p1, unsigned int *len1,
unsigned char **p2, unsigned int *len2) {
*p1 = &cbuf->data[cbuf->readpos];
Loading
Loading
Loading
Loading
@@ -38,12 +38,12 @@ typedef struct circbuf circbuffer;
circbuffer * cbuf_new(unsigned int size);
void cbuf_free(circbuffer * cbuf);
 
unsigned int cbuf_getused(circbuffer * cbuf); /* how much data stored */
unsigned int cbuf_getavail(circbuffer * cbuf); /* how much we can write */
unsigned int cbuf_writelen(circbuffer *cbuf); /* max linear write len */
unsigned int cbuf_getused(const circbuffer * cbuf); /* how much data stored */
unsigned int cbuf_getavail(const circbuffer * cbuf); /* how much we can write */
unsigned int cbuf_writelen(const circbuffer *cbuf); /* max linear write len */
 
/* returns pointers to the two portions of the circular buffer that can be read */
void cbuf_readptrs(circbuffer *cbuf,
void cbuf_readptrs(const circbuffer *cbuf,
unsigned char **p1, unsigned int *len1,
unsigned char **p2, unsigned int *len2);
unsigned char* cbuf_writeptr(circbuffer *cbuf, unsigned int len);
Loading
Loading
Loading
Loading
@@ -108,7 +108,7 @@ static int new_agent_chan(struct Channel * channel) {
data Any data, depending on packet type. Encoding as in the ssh packet
protocol.
*/
static buffer * agent_request(unsigned char type, buffer *data) {
static buffer * agent_request(unsigned char type, const buffer *data) {
 
buffer * payload = NULL;
buffer * inbuf = NULL;
Loading
Loading
@@ -230,7 +230,7 @@ out:
}
}
 
void cli_setup_agent(struct Channel *channel) {
void cli_setup_agent(const struct Channel *channel) {
if (!getenv("SSH_AUTH_SOCK")) {
return;
}
Loading
Loading
@@ -254,7 +254,7 @@ void cli_load_agent_keys(m_list *ret_list) {
}
 
void agent_buf_sign(buffer *sigblob, sign_key *key,
buffer *data_buf) {
const buffer *data_buf) {
buffer *request_data = NULL;
buffer *response = NULL;
unsigned int siglen;
Loading
Loading
Loading
Loading
@@ -331,7 +331,7 @@ int cli_auth_try() {
#if DROPBEAR_CLI_PASSWORD_AUTH || DROPBEAR_CLI_INTERACT_AUTH
/* A helper for getpass() that exits if the user cancels. The returned
* password is statically allocated by getpass() */
char* getpass_or_cancel(char* prompt)
char* getpass_or_cancel(const char* prompt)
{
char* password = NULL;
Loading
Loading
Loading
Loading
@@ -121,7 +121,7 @@ void recv_msg_userauth_pk_ok() {
}
 
void cli_buf_put_sign(buffer* buf, sign_key *key, int type,
buffer *data_buf) {
const buffer *data_buf) {
#if DROPBEAR_CLI_AGENTFWD
if (key->source == SIGNKEY_SOURCE_AGENT) {
/* Format the agent signature ourselves, as buf_put_sign would. */
Loading
Loading
Loading
Loading
@@ -38,8 +38,8 @@
static void cli_closechansess(struct Channel *channel);
static int cli_initchansess(struct Channel *channel);
static void cli_chansessreq(struct Channel *channel);
static void send_chansess_pty_req(struct Channel *channel);
static void send_chansess_shell_req(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 int cli_init_netcat(struct Channel *channel);
 
Loading
Loading
@@ -270,7 +270,7 @@ void cli_chansess_winchange() {
cli_ses.winchange = 0;
}
 
static void send_chansess_pty_req(struct Channel *channel) {
static void send_chansess_pty_req(const struct Channel *channel) {
 
char* term = NULL;
 
Loading
Loading
@@ -303,7 +303,7 @@ static void send_chansess_pty_req(struct Channel *channel) {
TRACE(("leave send_chansess_pty_req"))
}
 
static void send_chansess_shell_req(struct Channel *channel) {
static void send_chansess_shell_req(const struct Channel *channel) {
 
char* reqtype = NULL;
 
Loading
Loading
Loading
Loading
@@ -39,7 +39,7 @@
#include "ecc.h"
 
 
static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen);
static void checkhostkey(const unsigned char* keyblob, unsigned int keybloblen);
#define MAX_KNOWNHOSTS_LINE 4500
 
void send_msg_kexdh_init() {
Loading
Loading
@@ -185,7 +185,7 @@ void recv_msg_kexdh_reply() {
TRACE(("leave recv_msg_kexdh_init"))
}
 
static void ask_to_confirm(unsigned char* keyblob, unsigned int keybloblen,
static void ask_to_confirm(const unsigned char* keyblob, unsigned int keybloblen,
const char* algoname) {
 
char* fp = NULL;
Loading
Loading
@@ -282,7 +282,7 @@ out:
return hostsfile;
}
 
static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen) {
static void checkhostkey(const unsigned char* keyblob, unsigned int keybloblen) {
 
FILE *hostsfile = NULL;
int readonly = 0;
Loading
Loading
Loading
Loading
@@ -314,7 +314,7 @@ algo_type sshkex[] = {
* against.
* Returns DROPBEAR_SUCCESS if we have a match for algo, DROPBEAR_FAILURE
* otherwise */
int have_algo(char* algo, size_t algolen, algo_type algos[]) {
int have_algo(const char* algo, size_t algolen, const algo_type algos[]) {
 
int i;
 
Loading
Loading
@@ -329,7 +329,7 @@ int have_algo(char* algo, size_t algolen, algo_type algos[]) {
}
 
/* Output a comma separated list of algorithms to a buffer */
void buf_put_algolist(buffer * buf, algo_type localalgos[]) {
void buf_put_algolist(buffer * buf, const algo_type localalgos[]) {
 
unsigned int i, len;
unsigned int donefirst = 0;
Loading
Loading
@@ -501,7 +501,7 @@ get_algo_usable(algo_type algos[], const char * algo_name)
#if DROPBEAR_USER_ALGO_LIST
 
char *
algolist_string(algo_type algos[])
algolist_string(const algo_type algos[])
{
char *ret_list;
buffer *b = buf_new(200);
Loading
Loading
Loading
Loading
@@ -38,18 +38,18 @@
 
static void send_msg_channel_open_failure(unsigned int remotechan, int reason,
const char *text, const char *lang);
static void send_msg_channel_open_confirmation(struct Channel* channel,
static void send_msg_channel_open_confirmation(const struct Channel* channel,
unsigned int recvwindow,
unsigned int recvmaxpacket);
static int writechannel(struct Channel* channel, int fd, circbuffer *cbuf,
const unsigned char *moredata, unsigned int *morelen);
static void send_msg_channel_window_adjust(struct Channel *channel,
static void send_msg_channel_window_adjust(const struct Channel *channel,
unsigned int incr);
static void send_msg_channel_data(struct Channel *channel, int isextended);
static void send_msg_channel_eof(struct Channel *channel);
static void send_msg_channel_close(struct Channel *channel);
static void remove_channel(struct Channel *channel);
static unsigned int write_pending(struct Channel * channel);
static unsigned int write_pending(const struct Channel * channel);
static void check_close(struct Channel *channel);
static void close_chan_fd(struct Channel *channel, int fd, int how);
 
Loading
Loading
@@ -198,7 +198,7 @@ struct Channel* getchannel() {
}
 
/* Iterate through the channels, performing IO if available */
void channelio(fd_set *readfds, fd_set *writefds) {
void channelio(const fd_set *readfds, const fd_set *writefds) {
 
/* Listeners such as TCP, X11, agent-auth */
struct Channel *channel;
Loading
Loading
@@ -262,7 +262,7 @@ void channelio(fd_set *readfds, fd_set *writefds) {
 
/* Returns true if there is data remaining to be written to stdin or
* stderr of a channel's endpoint. */
static unsigned int write_pending(struct Channel * channel) {
static unsigned int write_pending(const struct Channel * channel) {
 
if (channel->writefd >= 0 && cbuf_getused(channel->writebuf) > 0) {
return 1;
Loading
Loading
@@ -903,7 +903,7 @@ void recv_msg_channel_window_adjust() {
 
/* Increment the incoming data window for a channel, and let the remote
* end know */
static void send_msg_channel_window_adjust(struct Channel* channel,
static void send_msg_channel_window_adjust(const struct Channel* channel,
unsigned int incr) {
 
TRACE(("sending window adjust %d", incr))
Loading
Loading
@@ -1008,7 +1008,7 @@ cleanup:
}
 
/* Send a failure message */
void send_msg_channel_failure(struct Channel *channel) {
void send_msg_channel_failure(const struct Channel *channel) {
 
TRACE(("enter send_msg_channel_failure"))
CHECKCLEARTOWRITE();
Loading
Loading
@@ -1021,7 +1021,7 @@ void send_msg_channel_failure(struct Channel *channel) {
}
 
/* Send a success message */
void send_msg_channel_success(struct Channel *channel) {
void send_msg_channel_success(const struct Channel *channel) {
 
TRACE(("enter send_msg_channel_success"))
CHECKCLEARTOWRITE();
Loading
Loading
@@ -1053,7 +1053,7 @@ static void send_msg_channel_open_failure(unsigned int remotechan,
 
/* Confirm a channel open, and let the remote end know what number we've
* allocated and the receive parameters */
static void send_msg_channel_open_confirmation(struct Channel* channel,
static void send_msg_channel_open_confirmation(const struct Channel* channel,
unsigned int recvwindow,
unsigned int recvmaxpacket) {
 
Loading
Loading
@@ -1239,8 +1239,8 @@ struct Channel* get_any_ready_channel() {
return NULL;
}
 
void start_send_channel_request(struct Channel *channel,
char *type) {
void start_send_channel_request(const struct Channel *channel,
const char *type) {
 
CHECKCLEARTOWRITE();
buf_putbyte(ses.writepayload, SSH_MSG_CHANNEL_REQUEST);
Loading
Loading
Loading
Loading
@@ -714,7 +714,7 @@ void free_kexcurve25519_param(struct kex_curve25519_param *param)
m_free(param);
}
 
void kexcurve25519_comb_key(struct kex_curve25519_param *param, buffer *buf_pub_them,
void kexcurve25519_comb_key(const struct kex_curve25519_param *param, const buffer *buf_pub_them,
sign_key *hostkey) {
unsigned char out[CURVE25519_LEN];
const unsigned char* Q_C = NULL;
Loading
Loading
Loading
Loading
@@ -141,7 +141,7 @@ out:
return ret;
}
 
void addrandom(unsigned char * buf, unsigned int len)
void addrandom(const unsigned char * buf, unsigned int len)
{
hash_state hs;
 
Loading
Loading
Loading
Loading
@@ -29,7 +29,7 @@
 
void seedrandom(void);
void genrandom(unsigned char* buf, unsigned int len);
void addrandom(unsigned char * buf, unsigned int len);
void addrandom(const unsigned char * buf, unsigned int len);
void gen_random_mpint(mp_int *max, mp_int *rand);
 
#endif /* DROPBEAR_RANDOM_H_ */
Loading
Loading
@@ -127,7 +127,7 @@ void dss_key_free(dropbear_dss_key *key) {
* mpint g
* mpint y
*/
void buf_put_dss_pub_key(buffer* buf, dropbear_dss_key *key) {
void buf_put_dss_pub_key(buffer* buf, const dropbear_dss_key *key) {
 
dropbear_assert(key != NULL);
buf_putstring(buf, SSH_SIGNKEY_DSS, SSH_SIGNKEY_DSS_LEN);
Loading
Loading
@@ -139,7 +139,7 @@ void buf_put_dss_pub_key(buffer* buf, dropbear_dss_key *key) {
}
 
/* Same as buf_put_dss_pub_key, but with the private "x" key appended */
void buf_put_dss_priv_key(buffer* buf, dropbear_dss_key *key) {
void buf_put_dss_priv_key(buffer* buf, const dropbear_dss_key *key) {
 
dropbear_assert(key != NULL);
buf_put_dss_pub_key(buf, key);
Loading
Loading
@@ -150,7 +150,7 @@ void buf_put_dss_priv_key(buffer* buf, dropbear_dss_key *key) {
#if DROPBEAR_SIGNKEY_VERIFY
/* Verify a DSS signature (in buf) made on data by the key given.
* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
int buf_dss_verify(buffer* buf, dropbear_dss_key *key, buffer *data_buf) {
int buf_dss_verify(buffer* buf, const dropbear_dss_key *key, const buffer *data_buf) {
unsigned char msghash[SHA1_HASH_SIZE];
hash_state hs;
int ret = DROPBEAR_FAILURE;
Loading
Loading
@@ -255,7 +255,7 @@ out:
 
/* Sign the data presented with key, writing the signature contents
* to the buffer */
void buf_put_dss_sign(buffer* buf, dropbear_dss_key *key, buffer *data_buf) {
void buf_put_dss_sign(buffer* buf, const dropbear_dss_key *key, const buffer *data_buf) {
unsigned char msghash[SHA1_HASH_SIZE];
unsigned int writelen;
unsigned int i;
Loading
Loading
Loading
Loading
@@ -44,14 +44,14 @@ typedef struct {
#define DSS_P_BITS 1024
#define DSS_Q_BITS 160
 
void buf_put_dss_sign(buffer* buf, dropbear_dss_key *key, buffer *data_buf);
void buf_put_dss_sign(buffer* buf, const dropbear_dss_key *key, const buffer *data_buf);
#if DROPBEAR_SIGNKEY_VERIFY
int buf_dss_verify(buffer* buf, dropbear_dss_key *key, buffer *data_buf);
int buf_dss_verify(buffer* buf, const dropbear_dss_key *key, const buffer *data_buf);
#endif
int buf_get_dss_pub_key(buffer* buf, dropbear_dss_key *key);
int buf_get_dss_priv_key(buffer* buf, dropbear_dss_key *key);
void buf_put_dss_pub_key(buffer* buf, dropbear_dss_key *key);
void buf_put_dss_priv_key(buffer* buf, dropbear_dss_key *key);
void buf_put_dss_pub_key(buffer* buf, const dropbear_dss_key *key);
void buf_put_dss_priv_key(buffer* buf, const dropbear_dss_key *key);
void dss_key_free(dropbear_dss_key *key);
 
#endif /* DROPBEAR_DSS */
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment