Commit f3f3b0ed authored by J.H.M. Dassen's avatar J.H.M. Dassen Committed by Niels Möller

Constness fixes (jdassen@wi.leidenuniv.nl)

Rev: src/atoms.c:1.6
Rev: src/channel.c:1.18
Rev: src/channel.h:1.20
Rev: src/client.c:1.39
Rev: src/client.h:1.15
Rev: src/debug.c:1.18
Rev: src/debug.h:1.9
Rev: src/disconnect.c:1.9
Rev: src/disconnect.h:1.4
Rev: src/format.c:1.21
Rev: src/format.h:1.16
Rev: src/keyexchange.h:1.26
Rev: src/server.c:1.29
Rev: src/server.h:1.10
Rev: src/symmetric/include/blowfish.h:1.2
Rev: src/symmetric/include/rc4.h:1.3
parent c913f8cd
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
struct atom_rassoc struct atom_rassoc
{ {
UINT8 *name; CONST UINT8 *name;
UINT32 length; UINT32 length;
}; };
struct atom_assoc *gperf_atom (const char *str, unsigned int len); struct atom_assoc *gperf_atom (CONST char *str, unsigned int len);
#include "atoms_gperf.c" #include "atoms_gperf.c"
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "xalloc.h" #include "xalloc.h"
#include <assert.h> #include <assert.h>
#include <string.h>
#define CLASS_DEFINE #define CLASS_DEFINE
#include "channel.h.x" #include "channel.h.x"
...@@ -87,7 +88,7 @@ struct lsh_string *format_global_failure(void) ...@@ -87,7 +88,7 @@ struct lsh_string *format_global_failure(void)
struct lsh_string *format_open_confirmation(struct ssh_channel *channel, struct lsh_string *format_open_confirmation(struct ssh_channel *channel,
UINT32 channel_number, UINT32 channel_number,
char *format, ...) const char *format, ...)
{ {
va_list args; va_list args;
UINT32 l1, l2; UINT32 l1, l2;
...@@ -117,7 +118,7 @@ struct lsh_string *format_open_confirmation(struct ssh_channel *channel, ...@@ -117,7 +118,7 @@ struct lsh_string *format_open_confirmation(struct ssh_channel *channel,
} }
struct lsh_string *format_open_failure(UINT32 channel, UINT32 reason, struct lsh_string *format_open_failure(UINT32 channel, UINT32 reason,
char *msg, char *language) const char *msg, const char *language)
{ {
return ssh_format("%c%i%i%z%z", SSH_MSG_CHANNEL_OPEN_FAILURE, return ssh_format("%c%i%i%z%z", SSH_MSG_CHANNEL_OPEN_FAILURE,
channel, reason, msg, language); channel, reason, msg, language);
...@@ -168,7 +169,8 @@ struct channel_table *make_channel_table(void) ...@@ -168,7 +169,8 @@ struct channel_table *make_channel_table(void)
/* Returns -1 if allocation fails */ /* Returns -1 if allocation fails */
int alloc_channel(struct channel_table *table) int alloc_channel(struct channel_table *table)
{ {
int i; /* FIXME: Use int here? */
UINT32 i;
for(i = table->next_channel; i < table->used_channels; i++) for(i = table->next_channel; i < table->used_channels; i++)
{ {
if (!table->channels[i]) if (!table->channels[i])
...@@ -1224,7 +1226,7 @@ struct close_callback *make_channel_close(struct ssh_channel *channel) ...@@ -1224,7 +1226,7 @@ struct close_callback *make_channel_close(struct ssh_channel *channel)
struct lsh_string *prepare_channel_open(struct channel_table *table, struct lsh_string *prepare_channel_open(struct channel_table *table,
int type, struct ssh_channel *channel, int type, struct ssh_channel *channel,
char *format, ...) const char *format, ...)
{ {
int index; int index;
...@@ -1260,7 +1262,8 @@ struct lsh_string *prepare_channel_open(struct channel_table *table, ...@@ -1260,7 +1262,8 @@ struct lsh_string *prepare_channel_open(struct channel_table *table,
} }
struct lsh_string *format_channel_request(int type, struct ssh_channel *channel, struct lsh_string *format_channel_request(int type, struct ssh_channel *channel,
int want_reply, char *format, ...) int want_reply, const char *format,
...)
{ {
va_list args; va_list args;
UINT32 l1, l2; UINT32 l1, l2;
......
...@@ -213,10 +213,10 @@ struct read_handler *make_channel_read_stderr(struct ssh_channel *channel); ...@@ -213,10 +213,10 @@ struct read_handler *make_channel_read_stderr(struct ssh_channel *channel);
struct lsh_string *format_global_failure(void); struct lsh_string *format_global_failure(void);
struct lsh_string *format_open_failure(UINT32 channel, UINT32 reason, struct lsh_string *format_open_failure(UINT32 channel, UINT32 reason,
char *msg, char *language); const char *msg, const char *language);
struct lsh_string *format_open_confirmation(struct ssh_channel *channel, struct lsh_string *format_open_confirmation(struct ssh_channel *channel,
UINT32 channel_number, UINT32 channel_number,
char *format, ...); const char *format, ...);
struct lsh_string *format_channel_success(UINT32 channel); struct lsh_string *format_channel_success(UINT32 channel);
struct lsh_string *format_channel_failure(UINT32 channel); struct lsh_string *format_channel_failure(UINT32 channel);
...@@ -226,10 +226,11 @@ struct lsh_string *prepare_window_adjust(struct ssh_channel *channel, ...@@ -226,10 +226,11 @@ struct lsh_string *prepare_window_adjust(struct ssh_channel *channel,
struct lsh_string *prepare_channel_open(struct channel_table *table, struct lsh_string *prepare_channel_open(struct channel_table *table,
int type, struct ssh_channel *channel, int type, struct ssh_channel *channel,
char *format, ...); const char *format, ...);
struct lsh_string *format_channel_request(int type, struct ssh_channel *channel, struct lsh_string *format_channel_request(int type, struct ssh_channel *channel,
int want_reply, char *format, ...); int want_reply, const char *format,
...);
struct lsh_string *format_channel_close(struct ssh_channel *channel); struct lsh_string *format_channel_close(struct ssh_channel *channel);
struct lsh_string *format_channel_eof(struct ssh_channel *channel); struct lsh_string *format_channel_eof(struct ssh_channel *channel);
......
...@@ -178,7 +178,7 @@ struct read_handler *make_client_read_line(struct ssh_connection *c) ...@@ -178,7 +178,7 @@ struct read_handler *make_client_read_line(struct ssh_connection *c)
struct fd_callback * struct fd_callback *
make_client_callback(struct io_backend *b, make_client_callback(struct io_backend *b,
char *comment, CONST char *comment,
UINT32 block_size, UINT32 block_size,
struct randomness *random, struct randomness *random,
struct make_kexinit *init, struct make_kexinit *init,
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
struct fd_callback * struct fd_callback *
make_client_callback(struct io_backend *b, make_client_callback(struct io_backend *b,
char *comment, CONST char *comment,
UINT32 block_size, UINT32 block_size,
struct randomness *random, struct randomness *random,
struct make_kexinit *init, struct make_kexinit *init,
......
...@@ -55,7 +55,7 @@ static int do_debug(struct abstract_write *w, ...@@ -55,7 +55,7 @@ static int do_debug(struct abstract_write *w,
} }
struct abstract_write * struct abstract_write *
make_packet_debug(struct abstract_write *continuation, char *prefix) make_packet_debug(struct abstract_write *continuation, const char *prefix)
{ {
NEW(packet_debug, closure); NEW(packet_debug, closure);
...@@ -66,7 +66,7 @@ make_packet_debug(struct abstract_write *continuation, char *prefix) ...@@ -66,7 +66,7 @@ make_packet_debug(struct abstract_write *continuation, char *prefix)
return &closure->super.super; return &closure->super.super;
} }
static struct lsh_string *make_debug_packet(char *msg, int always_display) static struct lsh_string *make_debug_packet(const char *msg, int always_display)
{ {
return ssh_format("%c%c%z%z", return ssh_format("%c%c%z%z",
SSH_MSG_DEBUG, SSH_MSG_DEBUG,
...@@ -77,7 +77,7 @@ static struct lsh_string *make_debug_packet(char *msg, int always_display) ...@@ -77,7 +77,7 @@ static struct lsh_string *make_debug_packet(char *msg, int always_display)
} }
/* Send a debug message to the other end. */ /* Send a debug message to the other end. */
int send_debug(struct abstract_write *write, char *msg, int always_display) int send_debug(struct abstract_write *write, const char *msg, int always_display)
{ {
return (debug_flag) return (debug_flag)
? A_WRITE(write, make_debug_packet(msg, always_display)) ? A_WRITE(write, make_debug_packet(msg, always_display))
...@@ -85,7 +85,7 @@ int send_debug(struct abstract_write *write, char *msg, int always_display) ...@@ -85,7 +85,7 @@ int send_debug(struct abstract_write *write, char *msg, int always_display)
} }
int send_verbose(struct abstract_write *write, char *msg, int always_display) int send_verbose(struct abstract_write *write, const char *msg, int always_display)
{ {
return (verbose_flag) return (verbose_flag)
? A_WRITE(write, make_debug_packet(msg, always_display)) ? A_WRITE(write, make_debug_packet(msg, always_display))
......
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
#include "abstract_io.h" #include "abstract_io.h"
struct abstract_write * struct abstract_write *
make_packet_debug(struct abstract_write *continuation, char *prefix); make_packet_debug(struct abstract_write *continuation, const char *prefix);
int send_debug(struct abstract_write *write, char *msg, int always_display); int send_debug(struct abstract_write *write, const char *msg, int always_display);
int send_verbose(struct abstract_write *write, char *msg, int always_display); int send_verbose(struct abstract_write *write, const char *msg, int always_display);
struct packet_handler *make_rec_debug_handler(void); struct packet_handler *make_rec_debug_handler(void);
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
#include "werror.h" #include "werror.h"
#include "xalloc.h" #include "xalloc.h"
struct lsh_string *format_disconnect(int code, char *msg, char *language) struct lsh_string *format_disconnect(int code, const char *msg,
const char *language)
{ {
return ssh_format("%c%i%z%z", return ssh_format("%c%i%z%z",
SSH_MSG_DISCONNECT, SSH_MSG_DISCONNECT,
......
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
#include "lsh_types.h" #include "lsh_types.h"
struct lsh_string *format_disconnect(int code, char *msg, char *language); struct lsh_string *format_disconnect(int code, const char *msg,
const char *language);
struct packet_handler *make_disconnect_handler(void); struct packet_handler *make_disconnect_handler(void);
#endif /* LSH_DISCONNECT_H_INCLUDED */ #endif /* LSH_DISCONNECT_H_INCLUDED */
...@@ -32,7 +32,9 @@ ...@@ -32,7 +32,9 @@
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
struct lsh_string *ssh_format(char *format, ...) struct lsh_string *ssh_format(const char *format, ...);
struct lsh_string *ssh_format(const char *format, ...)
{ {
va_list args; va_list args;
UINT32 length; UINT32 length;
...@@ -51,7 +53,7 @@ struct lsh_string *ssh_format(char *format, ...) ...@@ -51,7 +53,7 @@ struct lsh_string *ssh_format(char *format, ...)
return packet; return packet;
} }
UINT32 ssh_format_length(char *format, ...) UINT32 ssh_format_length(const char *format, ...)
{ {
va_list args; va_list args;
UINT32 length; UINT32 length;
...@@ -63,7 +65,7 @@ UINT32 ssh_format_length(char *format, ...) ...@@ -63,7 +65,7 @@ UINT32 ssh_format_length(char *format, ...)
return length; return length;
} }
void ssh_format_write(char *format, UINT32 length, UINT8 *buffer, ...) void ssh_format_write(const char *format, UINT32 length, UINT8 *buffer, ...)
{ {
va_list args; va_list args;
...@@ -73,7 +75,7 @@ void ssh_format_write(char *format, UINT32 length, UINT8 *buffer, ...) ...@@ -73,7 +75,7 @@ void ssh_format_write(char *format, UINT32 length, UINT8 *buffer, ...)
} }
UINT32 ssh_vformat_length(char *f, va_list args) UINT32 ssh_vformat_length(const char *f, va_list args)
{ {
UINT32 length = 0; UINT32 length = 0;
...@@ -170,7 +172,7 @@ UINT32 ssh_vformat_length(char *f, va_list args) ...@@ -170,7 +172,7 @@ UINT32 ssh_vformat_length(char *f, va_list args)
case 'A': case 'A':
{ {
struct int_list *l = va_arg(args, struct int_list *); struct int_list *l = va_arg(args, struct int_list *);
int n, i; UINT32 n, i;
for(n = i =0; i < LIST_LENGTH(l); i++) for(n = i =0; i < LIST_LENGTH(l); i++)
{ {
...@@ -212,7 +214,7 @@ UINT32 ssh_vformat_length(char *f, va_list args) ...@@ -212,7 +214,7 @@ UINT32 ssh_vformat_length(char *f, va_list args)
return length; return length;
} }
void ssh_vformat_write(char *f, UINT32 size, UINT8 *buffer, va_list args) void ssh_vformat_write(const char *f, UINT32 size, UINT8 *buffer, va_list args)
{ {
UINT8 *start = buffer; UINT8 *start = buffer;
...@@ -359,7 +361,7 @@ void ssh_vformat_write(char *f, UINT32 size, UINT8 *buffer, va_list args) ...@@ -359,7 +361,7 @@ void ssh_vformat_write(char *f, UINT32 size, UINT8 *buffer, va_list args)
{ {
struct int_list *l = va_arg(args, struct int_list *); struct int_list *l = va_arg(args, struct int_list *);
UINT8 *start = buffer; /* Where to store the length */ UINT8 *start = buffer; /* Where to store the length */
int n, i; UINT32 n, i;
if (!literal) if (!literal)
buffer += 4; buffer += 4;
...@@ -423,7 +425,7 @@ void ssh_vformat_write(char *f, UINT32 size, UINT8 *buffer, va_list args) ...@@ -423,7 +425,7 @@ void ssh_vformat_write(char *f, UINT32 size, UINT8 *buffer, va_list args)
* (not included in the length), to make it possible to pass the * (not included in the length), to make it possible to pass the
* string directly to C library functions. */ * string directly to C library functions. */
struct lsh_string *format_cstring(char *s) struct lsh_string *format_cstring(const char *s)
{ {
if (s) if (s)
{ {
......
...@@ -66,17 +66,17 @@ ...@@ -66,17 +66,17 @@
* "f" (as in free). Frees the input string after it has been copied. * "f" (as in free). Frees the input string after it has been copied.
* Applicable to %S only. */ * Applicable to %S only. */
struct lsh_string *ssh_format(char *format, ...); struct lsh_string *ssh_format(const char *format, ...);
UINT32 ssh_format_length(char *format, ...); UINT32 ssh_format_length(const char *format, ...);
void ssh_format_write(char *format, UINT32 length, UINT8 *buffer, ...); void ssh_format_write(const char *format, UINT32 length, UINT8 *buffer, ...);
UINT32 ssh_vformat_length(char *format, va_list args); UINT32 ssh_vformat_length(const char *format, va_list args);
void ssh_vformat_write(char *format, UINT32 length, UINT8 *buffer, va_list args); void ssh_vformat_write(const char *format, UINT32 length, UINT8 *buffer, va_list args);
/* Short cut */ /* Short cut */
#define lsh_string_dup(s) (ssh_format("%lS", (s))) #define lsh_string_dup(s) (ssh_format("%lS", (s)))
struct lsh_string *format_cstring(char *s); struct lsh_string *format_cstring(const char *s);
struct lsh_string *make_cstring(struct lsh_string *s, int free); struct lsh_string *make_cstring(struct lsh_string *s, int free);
#endif /* LSH_FORMAT_H_INCLUDED */ #endif /* LSH_FORMAT_H_INCLUDED */
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
*/ */
struct lsh_string *format_kex(struct kexinit *kex); struct lsh_string *format_kex(struct kexinit *kex);
int disconnect_kex_failed(struct ssh_connection *connection, char *msg); int disconnect_kex_failed(struct ssh_connection *connection, const char *msg);
struct crypto_instance *kex_make_encrypt(struct hash_instance *secret, struct crypto_instance *kex_make_encrypt(struct hash_instance *secret,
struct object_list *algorithms, struct object_list *algorithms,
......
...@@ -230,7 +230,7 @@ struct read_handler *make_server_read_line(struct ssh_connection *c) ...@@ -230,7 +230,7 @@ struct read_handler *make_server_read_line(struct ssh_connection *c)
struct fd_callback * struct fd_callback *
make_server_callback(struct io_backend *b, make_server_callback(struct io_backend *b,
char *comment, const char *comment,
UINT32 block_size, UINT32 block_size,
struct randomness *random, struct randomness *random,
struct make_kexinit *init, struct make_kexinit *init,
...@@ -574,12 +574,12 @@ static int make_pipe(int *fds) ...@@ -574,12 +574,12 @@ static int make_pipe(int *fds)
return 1; return 1;
} }
static char *make_env_pair(char *name, struct lsh_string *value) static char *make_env_pair(const char *name, struct lsh_string *value)
{ {
return ssh_format("%lz=%lS%c", name, value, 0)->data; return ssh_format("%lz=%lS%c", name, value, 0)->data;
} }
static char *make_env_pair_c(char *name, char *value) static char *make_env_pair_c(const char *name, char *value)
{ {
return ssh_format("%lz=%lz%c", name, value, 0)->data; return ssh_format("%lz=%lz%c", name, value, 0)->data;
} }
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
struct fd_callback * struct fd_callback *
make_server_callback(struct io_backend *b, make_server_callback(struct io_backend *b,
char *comment, const char *comment,
UINT32 block_size, UINT32 block_size,
struct randomness *random, struct randomness *random,
struct make_kexinit *init, struct make_kexinit *init,
......
...@@ -40,12 +40,12 @@ typedef struct { ...@@ -40,12 +40,12 @@ typedef struct {
} BLOWFISH_context; } BLOWFISH_context;
const char * CONST char *
blowfish_get_info( int algo, size_t *keylen, blowfish_get_info( int algo, size_t *keylen,
size_t *blocksize, size_t *contextsize, size_t *blocksize, size_t *contextsize,
int (**setkey)( void *c, const byte *key, unsigned keylen ), int (**setkey)( void *c, CONST byte *key, unsigned keylen ),
void (**encrypt)( void *c, byte *outbuf, const byte *inbuf ), void (**encrypt)( void *c, byte *outbuf, CONST byte *inbuf ),
void (**decrypt)( void *c, byte *outbuf, const byte *inbuf ) void (**decrypt)( void *c, byte *outbuf, CONST byte *inbuf )
); );
#endif /*G10_BLOWFISH_H*/ #endif /*G10_BLOWFISH_H*/
...@@ -16,7 +16,7 @@ struct rc4_ctx { ...@@ -16,7 +16,7 @@ struct rc4_ctx {
void rc4_init(struct rc4_ctx *ctx); void rc4_init(struct rc4_ctx *ctx);
#endif #endif
void rc4_set_key(struct rc4_ctx *ctx, const UINT8 *key, UINT32 len); void rc4_set_key(struct rc4_ctx *ctx, CONST UINT8 *key, UINT32 len);
void rc4_crypt(struct rc4_ctx *ctx, UINT8 *dest, const UINT8 *src, UINT32 len); void rc4_crypt(struct rc4_ctx *ctx, UINT8 *dest, CONST UINT8 *src, UINT32 len);
#endif /* RC4_H_INCLUDED */ #endif /* RC4_H_INCLUDED */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment