1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00

Giant const-correctness patch of doom!

Having found a lot of unfixed constness issues in recent development,
I thought perhaps it was time to get proactive, so I compiled the
whole codebase with -Wwrite-strings. That turned up a huge load of
const problems, which I've fixed in this commit: the Unix build now
goes cleanly through with -Wwrite-strings, and the Windows build is as
close as I could get it (there are some lingering issues due to
occasional Windows API functions like AcquireCredentialsHandle not
having the right constness).

Notable fallout beyond the purely mechanical changing of types:
 - the stuff saved by cmdline_save_param() is now explicitly
   dupstr()ed, and freed in cmdline_run_saved.
 - I couldn't make both string arguments to cmdline_process_param()
   const, because it intentionally writes to one of them in the case
   where it's the argument to -pw (in the vain hope of being at least
   slightly friendly to 'ps'), so elsewhere I had to temporarily
   dupstr() something for the sake of passing it to that function
 - I had to invent a silly parallel version of const_cmp() so I could
   pass const string literals in to lookup functions.
 - stripslashes() in pscp.c and psftp.c has the annoying strchr nature
This commit is contained in:
Simon Tatham 2015-05-15 11:15:42 +01:00
parent fb4fbe1158
commit 89da2ddf56
65 changed files with 559 additions and 450 deletions

View File

@ -91,7 +91,7 @@ static void no_progress(void *param, int action, int phase, int iprogress)
{ {
} }
void modalfatalbox(char *p, ...) void modalfatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");
@ -102,7 +102,7 @@ void modalfatalbox(char *p, ...)
cleanup_exit(1); cleanup_exit(1);
} }
void nonfatal(char *p, ...) void nonfatal(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "ERROR: "); fprintf(stderr, "ERROR: ");

View File

@ -44,15 +44,15 @@ struct cmdline_saved_param_set {
*/ */
static struct cmdline_saved_param_set saves[NPRIORITIES]; static struct cmdline_saved_param_set saves[NPRIORITIES];
static void cmdline_save_param(char *p, char *value, int pri) static void cmdline_save_param(const char *p, const char *value, int pri)
{ {
if (saves[pri].nsaved >= saves[pri].savesize) { if (saves[pri].nsaved >= saves[pri].savesize) {
saves[pri].savesize = saves[pri].nsaved + 32; saves[pri].savesize = saves[pri].nsaved + 32;
saves[pri].params = sresize(saves[pri].params, saves[pri].savesize, saves[pri].params = sresize(saves[pri].params, saves[pri].savesize,
struct cmdline_saved_param); struct cmdline_saved_param);
} }
saves[pri].params[saves[pri].nsaved].p = p; saves[pri].params[saves[pri].nsaved].p = dupstr(p);
saves[pri].params[saves[pri].nsaved].value = value; saves[pri].params[saves[pri].nsaved].value = dupstr(value);
saves[pri].nsaved++; saves[pri].nsaved++;
} }
@ -85,8 +85,8 @@ void cmdline_cleanup(void)
* return means that we aren't capable of processing the prompt and * return means that we aren't capable of processing the prompt and
* someone else should do it. * someone else should do it.
*/ */
int cmdline_get_passwd_input(prompts_t *p, unsigned char *in, int inlen) { int cmdline_get_passwd_input(prompts_t *p, const unsigned char *in, int inlen)
{
static int tried_once = 0; static int tried_once = 0;
/* /*
@ -125,7 +125,7 @@ int cmdline_get_passwd_input(prompts_t *p, unsigned char *in, int inlen) {
*/ */
int cmdline_tooltype = 0; int cmdline_tooltype = 0;
static int cmdline_check_unavailable(int flag, char *p) static int cmdline_check_unavailable(int flag, const char *p)
{ {
if (cmdline_tooltype & flag) { if (cmdline_tooltype & flag) {
cmdline_error("option \"%s\" not available in this tool", p); cmdline_error("option \"%s\" not available in this tool", p);
@ -159,7 +159,8 @@ static int cmdline_check_unavailable(int flag, char *p)
if (need_save < 0) return x; \ if (need_save < 0) return x; \
} while (0) } while (0)
int cmdline_process_param(char *p, char *value, int need_save, Conf *conf) int cmdline_process_param(const char *p, char *value,
int need_save, Conf *conf)
{ {
int ret = 0; int ret = 0;
@ -328,7 +329,8 @@ int cmdline_process_param(char *p, char *value, int need_save, Conf *conf)
sfree(host); sfree(host);
} }
if (!strcmp(p, "-m")) { if (!strcmp(p, "-m")) {
char *filename, *command; const char *filename;
char *command;
int cmdlen, cmdsize; int cmdlen, cmdsize;
FILE *fp; FILE *fp;
int c, d; int c, d;
@ -578,8 +580,13 @@ int cmdline_process_param(char *p, char *value, int need_save, Conf *conf)
void cmdline_run_saved(Conf *conf) void cmdline_run_saved(Conf *conf)
{ {
int pri, i; int pri, i;
for (pri = 0; pri < NPRIORITIES; pri++) for (pri = 0; pri < NPRIORITIES; pri++) {
for (i = 0; i < saves[pri].nsaved; i++) for (i = 0; i < saves[pri].nsaved; i++) {
cmdline_process_param(saves[pri].params[i].p, cmdline_process_param(saves[pri].params[i].p,
saves[pri].params[i].value, 0, conf); saves[pri].params[i].value, 0, conf);
sfree(saves[pri].params[i].p);
sfree(saves[pri].params[i].value);
}
saves[pri].nsaved = 0;
}
} }

42
conf.c
View File

@ -39,6 +39,16 @@ struct key {
} secondary; } secondary;
}; };
/* Variant form of struct key which doesn't contain dynamic data, used
* for lookups. */
struct constkey {
int primary;
union {
int i;
const char *s;
} secondary;
};
struct value { struct value {
union { union {
int intval; int intval;
@ -88,6 +98,29 @@ static int conf_cmp(void *av, void *bv)
} }
} }
static int conf_cmp_constkey(void *av, void *bv)
{
struct key *a = (struct key *)av;
struct constkey *b = (struct constkey *)bv;
if (a->primary < b->primary)
return -1;
else if (a->primary > b->primary)
return +1;
switch (subkeytypes[a->primary]) {
case TYPE_INT:
if (a->secondary.i < b->secondary.i)
return -1;
else if (a->secondary.i > b->secondary.i)
return +1;
return 0;
case TYPE_STR:
return strcmp(a->secondary.s, b->secondary.s);
default:
return 0;
}
}
/* /*
* Free any dynamic data items pointed to by a 'struct key'. We * Free any dynamic data items pointed to by a 'struct key'. We
* don't free the structure itself, since it's probably part of a * don't free the structure itself, since it's probably part of a
@ -286,7 +319,7 @@ char *conf_get_str_str(Conf *conf, int primary, const char *secondary)
char *conf_get_str_strs(Conf *conf, int primary, char *conf_get_str_strs(Conf *conf, int primary,
char *subkeyin, char **subkeyout) char *subkeyin, char **subkeyout)
{ {
struct key key; struct constkey key;
struct conf_entry *entry; struct conf_entry *entry;
assert(subkeytypes[primary] == TYPE_STR); assert(subkeytypes[primary] == TYPE_STR);
@ -297,7 +330,7 @@ char *conf_get_str_strs(Conf *conf, int primary,
entry = findrel234(conf->tree, &key, NULL, REL234_GT); entry = findrel234(conf->tree, &key, NULL, REL234_GT);
} else { } else {
key.secondary.s = ""; key.secondary.s = "";
entry = findrel234(conf->tree, &key, NULL, REL234_GE); entry = findrel234(conf->tree, &key, conf_cmp_constkey, REL234_GE);
} }
if (!entry || entry->key.primary != primary) if (!entry || entry->key.primary != primary)
return NULL; return NULL;
@ -307,7 +340,7 @@ char *conf_get_str_strs(Conf *conf, int primary,
char *conf_get_str_nthstrkey(Conf *conf, int primary, int n) char *conf_get_str_nthstrkey(Conf *conf, int primary, int n)
{ {
struct key key; struct constkey key;
struct conf_entry *entry; struct conf_entry *entry;
int index; int index;
@ -315,7 +348,8 @@ char *conf_get_str_nthstrkey(Conf *conf, int primary, int n)
assert(valuetypes[primary] == TYPE_STR); assert(valuetypes[primary] == TYPE_STR);
key.primary = primary; key.primary = primary;
key.secondary.s = ""; key.secondary.s = "";
entry = findrelpos234(conf->tree, &key, NULL, REL234_GE, &index); entry = findrelpos234(conf->tree, &key, conf_cmp_constkey,
REL234_GE, &index);
if (!entry || entry->key.primary != primary) if (!entry || entry->key.primary != primary)
return NULL; return NULL;
entry = index234(conf->tree, index + n); entry = index234(conf->tree, index + n);

View File

@ -356,7 +356,7 @@ static void cipherlist_handler(union control *ctrl, void *dlg,
if (event == EVENT_REFRESH) { if (event == EVENT_REFRESH) {
int i; int i;
static const struct { char *s; int c; } ciphers[] = { static const struct { const char *s; int c; } ciphers[] = {
{ "3DES", CIPHER_3DES }, { "3DES", CIPHER_3DES },
{ "Blowfish", CIPHER_BLOWFISH }, { "Blowfish", CIPHER_BLOWFISH },
{ "DES", CIPHER_DES }, { "DES", CIPHER_DES },
@ -372,7 +372,7 @@ static void cipherlist_handler(union control *ctrl, void *dlg,
for (i = 0; i < CIPHER_MAX; i++) { for (i = 0; i < CIPHER_MAX; i++) {
int c = conf_get_int_int(conf, CONF_ssh_cipherlist, i); int c = conf_get_int_int(conf, CONF_ssh_cipherlist, i);
int j; int j;
char *cstr = NULL; const char *cstr = NULL;
for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) { for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
if (ciphers[j].c == c) { if (ciphers[j].c == c) {
cstr = ciphers[j].s; cstr = ciphers[j].s;
@ -428,7 +428,7 @@ static void kexlist_handler(union control *ctrl, void *dlg,
if (event == EVENT_REFRESH) { if (event == EVENT_REFRESH) {
int i; int i;
static const struct { char *s; int k; } kexes[] = { static const struct { const char *s; int k; } kexes[] = {
{ "Diffie-Hellman group 1", KEX_DHGROUP1 }, { "Diffie-Hellman group 1", KEX_DHGROUP1 },
{ "Diffie-Hellman group 14", KEX_DHGROUP14 }, { "Diffie-Hellman group 14", KEX_DHGROUP14 },
{ "Diffie-Hellman group exchange", KEX_DHGEX }, { "Diffie-Hellman group exchange", KEX_DHGEX },
@ -444,7 +444,7 @@ static void kexlist_handler(union control *ctrl, void *dlg,
for (i = 0; i < KEX_MAX; i++) { for (i = 0; i < KEX_MAX; i++) {
int k = conf_get_int_int(conf, CONF_ssh_kexlist, i); int k = conf_get_int_int(conf, CONF_ssh_kexlist, i);
int j; int j;
char *kstr = NULL; const char *kstr = NULL;
for (j = 0; j < (sizeof kexes) / (sizeof kexes[0]); j++) { for (j = 0; j < (sizeof kexes) / (sizeof kexes[0]); j++) {
if (kexes[j].k == k) { if (kexes[j].k == k) {
kstr = kexes[j].s; kstr = kexes[j].s;
@ -472,7 +472,7 @@ static void printerbox_handler(union control *ctrl, void *dlg,
if (event == EVENT_REFRESH) { if (event == EVENT_REFRESH) {
int nprinters, i; int nprinters, i;
printer_enum *pe; printer_enum *pe;
char *printer; const char *printer;
dlg_update_start(ctrl, dlg); dlg_update_start(ctrl, dlg);
/* /*
@ -1119,7 +1119,8 @@ static void portfwd_handler(union control *ctrl, void *dlg,
} }
} else if (event == EVENT_ACTION) { } else if (event == EVENT_ACTION) {
if (ctrl == pfd->addbutton) { if (ctrl == pfd->addbutton) {
char *family, *type, *src, *key, *val; const char *family, *type;
char *src, *key, *val;
int whichbutton; int whichbutton;
#ifndef NO_IPV6 #ifndef NO_IPV6
@ -1178,7 +1179,8 @@ static void portfwd_handler(union control *ctrl, void *dlg,
if (i < 0) { if (i < 0) {
dlg_beep(dlg); dlg_beep(dlg);
} else { } else {
char *key, *val, *p; char *key, *p;
const char *val;
key = conf_get_str_nthstrkey(conf, CONF_portfwd, i); key = conf_get_str_nthstrkey(conf, CONF_portfwd, i);
if (key) { if (key) {
@ -1450,7 +1452,7 @@ void setup_config_box(struct controlbox *b, int midsession,
* logging can sensibly be available. * logging can sensibly be available.
*/ */
{ {
char *sshlogname, *sshrawlogname; const char *sshlogname, *sshrawlogname;
if ((midsession && protocol == PROT_SSH) || if ((midsession && protocol == PROT_SSH) ||
(!midsession && backend_from_proto(PROT_SSH))) { (!midsession && backend_from_proto(PROT_SSH))) {
sshlogname = "SSH packets"; sshlogname = "SSH packets";
@ -1927,7 +1929,7 @@ void setup_config_box(struct controlbox *b, int midsession,
#endif #endif
{ {
char *label = backend_from_proto(PROT_SSH) ? const char *label = backend_from_proto(PROT_SSH) ?
"Logical name of remote host (e.g. for SSH key lookup):" : "Logical name of remote host (e.g. for SSH key lookup):" :
"Logical name of remote host:"; "Logical name of remote host:";
s = ctrl_getset(b, "Connection", "identity", s = ctrl_getset(b, "Connection", "identity",

View File

@ -13,7 +13,7 @@
#include "putty.h" #include "putty.h"
#include "dialog.h" #include "dialog.h"
int ctrl_path_elements(char *path) int ctrl_path_elements(const char *path)
{ {
int i = 1; int i = 1;
while (*path) { while (*path) {
@ -25,7 +25,7 @@ int ctrl_path_elements(char *path)
/* Return the number of matching path elements at the starts of p1 and p2, /* Return the number of matching path elements at the starts of p1 and p2,
* or INT_MAX if the paths are identical. */ * or INT_MAX if the paths are identical. */
int ctrl_path_compare(char *p1, char *p2) int ctrl_path_compare(const char *p1, const char *p2)
{ {
int i = 0; int i = 0;
while (*p1 || *p2) { while (*p1 || *p2) {
@ -86,7 +86,7 @@ void ctrl_free_set(struct controlset *s)
* path. If that path doesn't exist, return the index where it * path. If that path doesn't exist, return the index where it
* should be inserted. * should be inserted.
*/ */
static int ctrl_find_set(struct controlbox *b, char *path, int start) static int ctrl_find_set(struct controlbox *b, const char *path, int start)
{ {
int i, last, thisone; int i, last, thisone;
@ -112,7 +112,7 @@ static int ctrl_find_set(struct controlbox *b, char *path, int start)
* path, or -1 if no such controlset exists. If -1 is passed as * path, or -1 if no such controlset exists. If -1 is passed as
* input, finds the first. * input, finds the first.
*/ */
int ctrl_find_path(struct controlbox *b, char *path, int index) int ctrl_find_path(struct controlbox *b, const char *path, int index)
{ {
if (index < 0) if (index < 0)
index = ctrl_find_set(b, path, 1); index = ctrl_find_set(b, path, 1);
@ -127,7 +127,7 @@ int ctrl_find_path(struct controlbox *b, char *path, int index)
/* Set up a panel title. */ /* Set up a panel title. */
struct controlset *ctrl_settitle(struct controlbox *b, struct controlset *ctrl_settitle(struct controlbox *b,
char *path, char *title) const char *path, const char *title)
{ {
struct controlset *s = snew(struct controlset); struct controlset *s = snew(struct controlset);
@ -151,8 +151,8 @@ struct controlset *ctrl_settitle(struct controlbox *b,
} }
/* Retrieve a pointer to a controlset, creating it if absent. */ /* Retrieve a pointer to a controlset, creating it if absent. */
struct controlset *ctrl_getset(struct controlbox *b, struct controlset *ctrl_getset(struct controlbox *b, const char *path,
char *path, char *name, char *boxtitle) const char *name, const char *boxtitle)
{ {
struct controlset *s; struct controlset *s;
int index = ctrl_find_set(b, path, 1); int index = ctrl_find_set(b, path, 1);
@ -257,8 +257,8 @@ union control *ctrl_columns(struct controlset *s, int ncolumns, ...)
return c; return c;
} }
union control *ctrl_editbox(struct controlset *s, char *label, char shortcut, union control *ctrl_editbox(struct controlset *s, const char *label,
int percentage, char shortcut, int percentage,
intorptr helpctx, handler_fn handler, intorptr helpctx, handler_fn handler,
intorptr context, intorptr context2) intorptr context, intorptr context2)
{ {
@ -272,8 +272,8 @@ union control *ctrl_editbox(struct controlset *s, char *label, char shortcut,
return c; return c;
} }
union control *ctrl_combobox(struct controlset *s, char *label, char shortcut, union control *ctrl_combobox(struct controlset *s, const char *label,
int percentage, char shortcut, int percentage,
intorptr helpctx, handler_fn handler, intorptr helpctx, handler_fn handler,
intorptr context, intorptr context2) intorptr context, intorptr context2)
{ {
@ -293,7 +293,7 @@ union control *ctrl_combobox(struct controlset *s, char *label, char shortcut,
* title is expected to be followed by a shortcut _iff_ `shortcut' * title is expected to be followed by a shortcut _iff_ `shortcut'
* is NO_SHORTCUT. * is NO_SHORTCUT.
*/ */
union control *ctrl_radiobuttons(struct controlset *s, char *label, union control *ctrl_radiobuttons(struct controlset *s, const char *label,
char shortcut, int ncolumns, intorptr helpctx, char shortcut, int ncolumns, intorptr helpctx,
handler_fn handler, intorptr context, ...) handler_fn handler, intorptr context, ...)
{ {
@ -339,9 +339,9 @@ union control *ctrl_radiobuttons(struct controlset *s, char *label,
return c; return c;
} }
union control *ctrl_pushbutton(struct controlset *s,char *label,char shortcut, union control *ctrl_pushbutton(struct controlset *s, const char *label,
intorptr helpctx, handler_fn handler, char shortcut, intorptr helpctx,
intorptr context) handler_fn handler, intorptr context)
{ {
union control *c = ctrl_new(s, CTRL_BUTTON, helpctx, handler, context); union control *c = ctrl_new(s, CTRL_BUTTON, helpctx, handler, context);
c->button.label = label ? dupstr(label) : NULL; c->button.label = label ? dupstr(label) : NULL;
@ -351,9 +351,9 @@ union control *ctrl_pushbutton(struct controlset *s,char *label,char shortcut,
return c; return c;
} }
union control *ctrl_listbox(struct controlset *s,char *label,char shortcut, union control *ctrl_listbox(struct controlset *s, const char *label,
intorptr helpctx, handler_fn handler, char shortcut, intorptr helpctx,
intorptr context) handler_fn handler, intorptr context)
{ {
union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context); union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
c->listbox.label = label ? dupstr(label) : NULL; c->listbox.label = label ? dupstr(label) : NULL;
@ -368,8 +368,8 @@ union control *ctrl_listbox(struct controlset *s,char *label,char shortcut,
return c; return c;
} }
union control *ctrl_droplist(struct controlset *s, char *label, char shortcut, union control *ctrl_droplist(struct controlset *s, const char *label,
int percentage, intorptr helpctx, char shortcut, int percentage, intorptr helpctx,
handler_fn handler, intorptr context) handler_fn handler, intorptr context)
{ {
union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context); union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
@ -385,9 +385,9 @@ union control *ctrl_droplist(struct controlset *s, char *label, char shortcut,
return c; return c;
} }
union control *ctrl_draglist(struct controlset *s,char *label,char shortcut, union control *ctrl_draglist(struct controlset *s, const char *label,
intorptr helpctx, handler_fn handler, char shortcut, intorptr helpctx,
intorptr context) handler_fn handler, intorptr context)
{ {
union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context); union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
c->listbox.label = label ? dupstr(label) : NULL; c->listbox.label = label ? dupstr(label) : NULL;
@ -402,10 +402,10 @@ union control *ctrl_draglist(struct controlset *s,char *label,char shortcut,
return c; return c;
} }
union control *ctrl_filesel(struct controlset *s,char *label,char shortcut, union control *ctrl_filesel(struct controlset *s, const char *label,
char const *filter, int write, char *title, char shortcut, const char *filter, int write,
intorptr helpctx, handler_fn handler, const char *title, intorptr helpctx,
intorptr context) handler_fn handler, intorptr context)
{ {
union control *c = ctrl_new(s, CTRL_FILESELECT, helpctx, handler, context); union control *c = ctrl_new(s, CTRL_FILESELECT, helpctx, handler, context);
c->fileselect.label = label ? dupstr(label) : NULL; c->fileselect.label = label ? dupstr(label) : NULL;
@ -416,9 +416,9 @@ union control *ctrl_filesel(struct controlset *s,char *label,char shortcut,
return c; return c;
} }
union control *ctrl_fontsel(struct controlset *s,char *label,char shortcut, union control *ctrl_fontsel(struct controlset *s, const char *label,
intorptr helpctx, handler_fn handler, char shortcut, intorptr helpctx,
intorptr context) handler_fn handler, intorptr context)
{ {
union control *c = ctrl_new(s, CTRL_FONTSELECT, helpctx, handler, context); union control *c = ctrl_new(s, CTRL_FONTSELECT, helpctx, handler, context);
c->fontselect.label = label ? dupstr(label) : NULL; c->fontselect.label = label ? dupstr(label) : NULL;
@ -433,16 +433,17 @@ union control *ctrl_tabdelay(struct controlset *s, union control *ctrl)
return c; return c;
} }
union control *ctrl_text(struct controlset *s, char *text, intorptr helpctx) union control *ctrl_text(struct controlset *s, const char *text,
intorptr helpctx)
{ {
union control *c = ctrl_new(s, CTRL_TEXT, helpctx, NULL, P(NULL)); union control *c = ctrl_new(s, CTRL_TEXT, helpctx, NULL, P(NULL));
c->text.label = dupstr(text); c->text.label = dupstr(text);
return c; return c;
} }
union control *ctrl_checkbox(struct controlset *s, char *label, char shortcut, union control *ctrl_checkbox(struct controlset *s, const char *label,
intorptr helpctx, handler_fn handler, char shortcut, intorptr helpctx,
intorptr context) handler_fn handler, intorptr context)
{ {
union control *c = ctrl_new(s, CTRL_CHECKBOX, helpctx, handler, context); union control *c = ctrl_new(s, CTRL_CHECKBOX, helpctx, handler, context);
c->checkbox.label = label ? dupstr(label) : NULL; c->checkbox.label = label ? dupstr(label) : NULL;

View File

@ -458,10 +458,10 @@ void ctrl_free_box(struct controlbox *);
/* Set up a panel title. */ /* Set up a panel title. */
struct controlset *ctrl_settitle(struct controlbox *, struct controlset *ctrl_settitle(struct controlbox *,
char *path, char *title); const char *path, const char *title);
/* Retrieve a pointer to a controlset, creating it if absent. */ /* Retrieve a pointer to a controlset, creating it if absent. */
struct controlset *ctrl_getset(struct controlbox *, struct controlset *ctrl_getset(struct controlbox *, const char *path,
char *path, char *name, char *boxtitle); const char *name, const char *boxtitle);
void ctrl_free_set(struct controlset *); void ctrl_free_set(struct controlset *);
void ctrl_free(union control *); void ctrl_free(union control *);
@ -493,12 +493,12 @@ void *ctrl_alloc_with_free(struct controlbox *b, size_t size,
/* `ncolumns' is followed by that many percentages, as integers. */ /* `ncolumns' is followed by that many percentages, as integers. */
union control *ctrl_columns(struct controlset *, int ncolumns, ...); union control *ctrl_columns(struct controlset *, int ncolumns, ...);
union control *ctrl_editbox(struct controlset *, char *label, char shortcut, union control *ctrl_editbox(struct controlset *, const char *label,
int percentage, intorptr helpctx, char shortcut, int percentage, intorptr helpctx,
handler_fn handler, handler_fn handler,
intorptr context, intorptr context2); intorptr context, intorptr context2);
union control *ctrl_combobox(struct controlset *, char *label, char shortcut, union control *ctrl_combobox(struct controlset *, const char *label,
int percentage, intorptr helpctx, char shortcut, int percentage, intorptr helpctx,
handler_fn handler, handler_fn handler,
intorptr context, intorptr context2); intorptr context, intorptr context2);
/* /*
@ -507,32 +507,32 @@ union control *ctrl_combobox(struct controlset *, char *label, char shortcut,
* title is expected to be followed by a shortcut _iff_ `shortcut' * title is expected to be followed by a shortcut _iff_ `shortcut'
* is NO_SHORTCUT. * is NO_SHORTCUT.
*/ */
union control *ctrl_radiobuttons(struct controlset *, char *label, union control *ctrl_radiobuttons(struct controlset *, const char *label,
char shortcut, int ncolumns, char shortcut, int ncolumns, intorptr helpctx,
intorptr helpctx,
handler_fn handler, intorptr context, ...); handler_fn handler, intorptr context, ...);
union control *ctrl_pushbutton(struct controlset *,char *label,char shortcut, union control *ctrl_pushbutton(struct controlset *, const char *label,
intorptr helpctx, char shortcut, intorptr helpctx,
handler_fn handler, intorptr context); handler_fn handler, intorptr context);
union control *ctrl_listbox(struct controlset *,char *label,char shortcut, union control *ctrl_listbox(struct controlset *, const char *label,
intorptr helpctx, char shortcut, intorptr helpctx,
handler_fn handler, intorptr context); handler_fn handler, intorptr context);
union control *ctrl_droplist(struct controlset *, char *label, char shortcut, union control *ctrl_droplist(struct controlset *, const char *label,
int percentage, intorptr helpctx, char shortcut, int percentage, intorptr helpctx,
handler_fn handler, intorptr context); handler_fn handler, intorptr context);
union control *ctrl_draglist(struct controlset *,char *label,char shortcut, union control *ctrl_draglist(struct controlset *, const char *label,
intorptr helpctx, char shortcut, intorptr helpctx,
handler_fn handler, intorptr context); handler_fn handler, intorptr context);
union control *ctrl_filesel(struct controlset *,char *label,char shortcut, union control *ctrl_filesel(struct controlset *, const char *label,
char const *filter, int write, char *title, char shortcut, const char *filter, int write,
intorptr helpctx, const char *title, intorptr helpctx,
handler_fn handler, intorptr context); handler_fn handler, intorptr context);
union control *ctrl_fontsel(struct controlset *,char *label,char shortcut, union control *ctrl_fontsel(struct controlset *, const char *label,
intorptr helpctx, char shortcut, intorptr helpctx,
handler_fn handler, intorptr context); handler_fn handler, intorptr context);
union control *ctrl_text(struct controlset *, char *text, intorptr helpctx); union control *ctrl_text(struct controlset *, const char *text,
union control *ctrl_checkbox(struct controlset *, char *label, char shortcut, intorptr helpctx);
intorptr helpctx, union control *ctrl_checkbox(struct controlset *, const char *label,
char shortcut, intorptr helpctx,
handler_fn handler, intorptr context); handler_fn handler, intorptr context);
union control *ctrl_tabdelay(struct controlset *, union control *); union control *ctrl_tabdelay(struct controlset *, union control *);
@ -597,7 +597,7 @@ union control *dlg_last_focused(union control *ctrl, void *dlg);
* error; dlg_error() puts up a message-box or equivalent. * error; dlg_error() puts up a message-box or equivalent.
*/ */
void dlg_beep(void *dlg); void dlg_beep(void *dlg);
void dlg_error_msg(void *dlg, char *msg); void dlg_error_msg(void *dlg, const char *msg);
/* /*
* This function signals to the front end that the dialog's * This function signals to the front end that the dialog's
* processing is completed, and passes an integer value (typically * processing is completed, and passes an integer value (typically
@ -647,8 +647,8 @@ void dlg_refresh(union control *ctrl, void *dlg);
* ... process this controlset ... * ... process this controlset ...
* } * }
*/ */
int ctrl_find_path(struct controlbox *b, char *path, int index); int ctrl_find_path(struct controlbox *b, const char *path, int index);
int ctrl_path_elements(char *path); int ctrl_path_elements(const char *path);
/* Return the number of matching path elements at the starts of p1 and p2, /* Return the number of matching path elements at the starts of p1 and p2,
* or INT_MAX if the paths are identical. */ * or INT_MAX if the paths are identical. */
int ctrl_path_compare(char *p1, char *p2); int ctrl_path_compare(const char *p1, const char *p2);

View File

@ -362,7 +362,8 @@ static struct openssh_pem_key *load_openssh_pem_key(const Filename *filename,
struct openssh_pem_key *ret; struct openssh_pem_key *ret;
FILE *fp = NULL; FILE *fp = NULL;
char *line = NULL; char *line = NULL;
char *errmsg, *p; const char *errmsg;
char *p;
int headers_done; int headers_done;
char base64_bit[4]; char base64_bit[4];
int base64_chars = 0; int base64_chars = 0;
@ -570,7 +571,7 @@ struct ssh2_userkey *openssh_pem_read(const Filename *filename,
int ret, id, len, flags; int ret, id, len, flags;
int i, num_integers; int i, num_integers;
struct ssh2_userkey *retval = NULL; struct ssh2_userkey *retval = NULL;
char *errmsg; const char *errmsg;
unsigned char *blob; unsigned char *blob;
int blobsize = 0, blobptr, privptr; int blobsize = 0, blobptr, privptr;
char *modptr = NULL; char *modptr = NULL;
@ -910,7 +911,7 @@ int openssh_pem_write(const Filename *filename, struct ssh2_userkey *key,
int outlen; int outlen;
struct mpint_pos numbers[9]; struct mpint_pos numbers[9];
int nnumbers, pos, len, seqlen, i; int nnumbers, pos, len, seqlen, i;
char *header, *footer; const char *header, *footer;
char zero[1]; char zero[1];
unsigned char iv[8]; unsigned char iv[8];
int ret = 0; int ret = 0;
@ -1283,7 +1284,8 @@ static struct openssh_new_key *load_openssh_new_key(const Filename *filename,
struct openssh_new_key *ret; struct openssh_new_key *ret;
FILE *fp = NULL; FILE *fp = NULL;
char *line = NULL; char *line = NULL;
char *errmsg, *p; const char *errmsg;
char *p;
char base64_bit[4]; char base64_bit[4];
int base64_chars = 0; int base64_chars = 0;
const void *filedata; const void *filedata;
@ -1526,7 +1528,7 @@ struct ssh2_userkey *openssh_new_read(const Filename *filename,
struct ssh2_userkey *retkey; struct ssh2_userkey *retkey;
int i; int i;
struct ssh2_userkey *retval = NULL; struct ssh2_userkey *retval = NULL;
char *errmsg; const char *errmsg;
unsigned char *blob; unsigned char *blob;
int blobsize = 0; int blobsize = 0;
unsigned checkint0, checkint1; unsigned checkint0, checkint1;
@ -1981,7 +1983,8 @@ static struct sshcom_key *load_sshcom_key(const Filename *filename,
FILE *fp; FILE *fp;
char *line = NULL; char *line = NULL;
int hdrstart, len; int hdrstart, len;
char *errmsg, *p; const char *errmsg;
char *p;
int headers_done; int headers_done;
char base64_bit[4]; char base64_bit[4];
int base64_chars = 0; int base64_chars = 0;
@ -2226,7 +2229,7 @@ struct ssh2_userkey *sshcom_read(const Filename *filename, char *passphrase,
const char **errmsg_p) const char **errmsg_p)
{ {
struct sshcom_key *key = load_sshcom_key(filename, errmsg_p); struct sshcom_key *key = load_sshcom_key(filename, errmsg_p);
char *errmsg; const char *errmsg;
int pos, len; int pos, len;
const char prefix_rsa[] = "if-modn{sign{rsa"; const char prefix_rsa[] = "if-modn{sign{rsa";
const char prefix_dsa[] = "dl-modp{sign{dsa"; const char prefix_dsa[] = "dl-modp{sign{dsa";
@ -2470,7 +2473,7 @@ int sshcom_write(const Filename *filename, struct ssh2_userkey *key,
int outlen; int outlen;
struct mpint_pos numbers[6]; struct mpint_pos numbers[6];
int nnumbers, initial_zero, pos, lenpos, i; int nnumbers, initial_zero, pos, lenpos, i;
char *type; const char *type;
char *ciphertext; char *ciphertext;
int cipherlen; int cipherlen;
int ret = 0; int ret = 0;
@ -2566,7 +2569,7 @@ int sshcom_write(const Filename *filename, struct ssh2_userkey *key,
pos += 4; /* length field, fill in later */ pos += 4; /* length field, fill in later */
pos += put_string(outblob+pos, type, strlen(type)); pos += put_string(outblob+pos, type, strlen(type));
{ {
char *ciphertype = passphrase ? "3des-cbc" : "none"; const char *ciphertype = passphrase ? "3des-cbc" : "none";
pos += put_string(outblob+pos, ciphertype, strlen(ciphertype)); pos += put_string(outblob+pos, ciphertype, strlen(ciphertype));
} }
lenpos = pos; /* remember this position */ lenpos = pos; /* remember this position */

View File

@ -22,7 +22,7 @@
(ldisc->back->ldisc(ldisc->backhandle, LD_EDIT) || \ (ldisc->back->ldisc(ldisc->backhandle, LD_EDIT) || \
term_ldisc(ldisc->term, LD_EDIT)))) term_ldisc(ldisc->term, LD_EDIT))))
static void c_write(Ldisc ldisc, char *buf, int len) static void c_write(Ldisc ldisc, const char *buf, int len)
{ {
from_backend(ldisc->frontend, 0, buf, len); from_backend(ldisc->frontend, 0, buf, len);
} }
@ -134,7 +134,7 @@ void ldisc_echoedit_update(void *handle)
frontend_echoedit_update(ldisc->frontend, ECHOING, EDITING); frontend_echoedit_update(ldisc->frontend, ECHOING, EDITING);
} }
void ldisc_send(void *handle, char *buf, int len, int interactive) void ldisc_send(void *handle, const char *buf, int len, int interactive)
{ {
Ldisc ldisc = (Ldisc) handle; Ldisc ldisc = (Ldisc) handle;
int keyflag = 0; int keyflag = 0;

View File

@ -13,7 +13,7 @@
#include "ldisc.h" #include "ldisc.h"
void lpage_send(void *handle, void lpage_send(void *handle,
int codepage, char *buf, int len, int interactive) int codepage, const char *buf, int len, int interactive)
{ {
Ldisc ldisc = (Ldisc)handle; Ldisc ldisc = (Ldisc)handle;
wchar_t *widebuffer = 0; wchar_t *widebuffer = 0;
@ -34,7 +34,7 @@ void lpage_send(void *handle,
sfree(widebuffer); sfree(widebuffer);
} }
void luni_send(void *handle, wchar_t * widebuf, int len, int interactive) void luni_send(void *handle, const wchar_t *widebuf, int len, int interactive)
{ {
Ldisc ldisc = (Ldisc)handle; Ldisc ldisc = (Ldisc)handle;
int ratio = (in_utf(ldisc->term))?3:1; int ratio = (in_utf(ldisc->term))?3:1;

View File

@ -233,7 +233,7 @@ void log_eventlog(void *handle, const char *event)
* Set of blanking areas must be in increasing order. * Set of blanking areas must be in increasing order.
*/ */
void log_packet(void *handle, int direction, int type, void log_packet(void *handle, int direction, int type,
char *texttype, const void *data, int len, const char *texttype, const void *data, int len,
int n_blanks, const struct logblank_t *blanks, int n_blanks, const struct logblank_t *blanks,
const unsigned long *seq, const unsigned long *seq,
unsigned downstream_id, const char *additional_log_text) unsigned downstream_id, const char *additional_log_text)

View File

@ -1736,7 +1736,7 @@ void dlg_beep(void *dv)
NSBeep(); NSBeep();
} }
void dlg_error_msg(void *dv, char *msg) void dlg_error_msg(void *dv, const char *msg)
{ {
/* FIXME */ /* FIXME */
} }

View File

@ -490,7 +490,7 @@ static void connection_fatal_callback(void *ctx, int result)
[win endSession:FALSE]; [win endSession:FALSE];
} }
void connection_fatal(void *frontend, char *p, ...) void connection_fatal(void *frontend, const char *p, ...)
{ {
SessionWindow *win = (SessionWindow *)frontend; SessionWindow *win = (SessionWindow *)frontend;
va_list ap; va_list ap;

View File

@ -58,7 +58,7 @@ char *x_get_default(const char *key)
return NULL; /* this is a stub */ return NULL; /* this is a stub */
} }
static void commonfatalbox(char *p, va_list ap) static void commonfatalbox(const char *p, va_list ap)
{ {
char errorbuf[2048]; char errorbuf[2048];
NSAlert *alert; NSAlert *alert;
@ -85,7 +85,7 @@ static void commonfatalbox(char *p, va_list ap)
exit(1); exit(1);
} }
void nonfatal(void *frontend, char *p, ...) void nonfatal(void *frontend, const char *p, ...)
{ {
char *errorbuf; char *errorbuf;
NSAlert *alert; NSAlert *alert;
@ -103,7 +103,7 @@ void nonfatal(void *frontend, char *p, ...)
sfree(errorbuf); sfree(errorbuf);
} }
void fatalbox(char *p, ...) void fatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
va_start(ap, p); va_start(ap, p);
@ -111,7 +111,7 @@ void fatalbox(char *p, ...)
va_end(ap); va_end(ap);
} }
void modalfatalbox(char *p, ...) void modalfatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
va_start(ap, p); va_start(ap, p);
@ -119,7 +119,7 @@ void modalfatalbox(char *p, ...)
va_end(ap); va_end(ap);
} }
void cmdline_error(char *p, ...) void cmdline_error(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "%s: ", appname); fprintf(stderr, "%s: ", appname);

View File

@ -888,7 +888,7 @@ int from_backend_untrusted(void *frontend, const char *data, int len)
return [win fromBackendUntrusted:data len:len]; return [win fromBackendUntrusted:data len:len];
} }
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen) int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{ {
SessionWindow *win = (SessionWindow *)p->frontend; SessionWindow *win = (SessionWindow *)p->frontend;
Terminal *term = [win term]; Terminal *term = [win term];

4
misc.c
View File

@ -175,7 +175,7 @@ int main(void)
return fails != 0 ? 1 : 0; return fails != 0 ? 1 : 0;
} }
/* Stubs to stop the rest of this module causing compile failures. */ /* Stubs to stop the rest of this module causing compile failures. */
void modalfatalbox(char *fmt, ...) {} void modalfatalbox(const char *fmt, ...) {}
int conf_get_int(Conf *conf, int primary) { return 0; } int conf_get_int(Conf *conf, int primary) { return 0; }
char *conf_get_str(Conf *conf, int primary) { return NULL; } char *conf_get_str(Conf *conf, int primary) { return NULL; }
#endif /* TEST_HOST_STRFOO */ #endif /* TEST_HOST_STRFOO */
@ -830,7 +830,7 @@ void safefree(void *ptr)
*/ */
#ifdef DEBUG #ifdef DEBUG
extern void dputs(char *); /* defined in per-platform *misc.c */ extern void dputs(const char *); /* defined in per-platform *misc.c */
void debug_printf(const char *fmt, ...) void debug_printf(const char *fmt, ...)
{ {

View File

@ -92,20 +92,20 @@ struct plug_function_table {
/* proxy indirection layer */ /* proxy indirection layer */
/* NB, control of 'addr' is passed via new_connection, which takes /* NB, control of 'addr' is passed via new_connection, which takes
* responsibility for freeing it */ * responsibility for freeing it */
Socket new_connection(SockAddr addr, char *hostname, Socket new_connection(SockAddr addr, const char *hostname,
int port, int privport, int port, int privport,
int oobinline, int nodelay, int keepalive, int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf); Plug plug, Conf *conf);
Socket new_listener(char *srcaddr, int port, Plug plug, int local_host_only, Socket new_listener(const char *srcaddr, int port, Plug plug,
Conf *conf, int addressfamily); int local_host_only, Conf *conf, int addressfamily);
SockAddr name_lookup(char *host, int port, char **canonicalname, SockAddr name_lookup(const char *host, int port, char **canonicalname,
Conf *conf, int addressfamily); Conf *conf, int addressfamily);
int proxy_for_destination (SockAddr addr, const char *hostname, int port, int proxy_for_destination (SockAddr addr, const char *hostname, int port,
Conf *conf); Conf *conf);
/* platform-dependent callback from new_connection() */ /* platform-dependent callback from new_connection() */
/* (same caveat about addr as new_connection()) */ /* (same caveat about addr as new_connection()) */
Socket platform_new_connection(SockAddr addr, char *hostname, Socket platform_new_connection(SockAddr addr, const char *hostname,
int port, int privport, int port, int privport,
int oobinline, int nodelay, int keepalive, int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf); Plug plug, Conf *conf);
@ -137,7 +137,8 @@ SockAddr sk_addr_dup(SockAddr addr);
Socket sk_new(SockAddr addr, int port, int privport, int oobinline, Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
int nodelay, int keepalive, Plug p); int nodelay, int keepalive, Plug p);
Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, int address_family); Socket sk_newlistener(const char *srcaddr, int port, Plug plug,
int local_host_only, int address_family);
#define sk_plug(s,p) (((*s)->plug) (s, p)) #define sk_plug(s,p) (((*s)->plug) (s, p))
#define sk_close(s) (((*s)->close) (s)) #define sk_close(s) (((*s)->close) (s))

View File

@ -362,7 +362,7 @@ int proxy_for_destination (SockAddr addr, const char *hostname,
return 1; return 1;
} }
SockAddr name_lookup(char *host, int port, char **canonicalname, SockAddr name_lookup(const char *host, int port, char **canonicalname,
Conf *conf, int addressfamily) Conf *conf, int addressfamily)
{ {
if (conf_get_int(conf, CONF_proxy_type) != PROXY_NONE && if (conf_get_int(conf, CONF_proxy_type) != PROXY_NONE &&
@ -375,7 +375,7 @@ SockAddr name_lookup(char *host, int port, char **canonicalname,
return sk_namelookup(host, canonicalname, addressfamily); return sk_namelookup(host, canonicalname, addressfamily);
} }
Socket new_connection(SockAddr addr, char *hostname, Socket new_connection(SockAddr addr, const char *hostname,
int port, int privport, int port, int privport,
int oobinline, int nodelay, int keepalive, int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf) Plug plug, Conf *conf)
@ -488,8 +488,8 @@ Socket new_connection(SockAddr addr, char *hostname,
return sk_new(addr, port, privport, oobinline, nodelay, keepalive, plug); return sk_new(addr, port, privport, oobinline, nodelay, keepalive, plug);
} }
Socket new_listener(char *srcaddr, int port, Plug plug, int local_host_only, Socket new_listener(const char *srcaddr, int port, Plug plug,
Conf *conf, int addressfamily) int local_host_only, Conf *conf, int addressfamily)
{ {
/* TODO: SOCKS (and potentially others) support inbound /* TODO: SOCKS (and potentially others) support inbound
* TODO: connections via the proxy. support them. * TODO: connections via the proxy. support them.

View File

@ -19,7 +19,7 @@ struct Socket_proxy_tag {
const struct socket_function_table *fn; const struct socket_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */ /* the above variable absolutely *must* be the first in this structure */
char * error; const char *error;
Socket sub_socket; Socket sub_socket;
Plug plug; Plug plug;

117
pscp.c
View File

@ -48,9 +48,9 @@ static void *backhandle;
static Conf *conf; static Conf *conf;
int sent_eof = FALSE; int sent_eof = FALSE;
static void source(char *src); static void source(const char *src);
static void rsource(char *src); static void rsource(const char *src);
static void sink(char *targ, char *src); static void sink(const char *targ, const char *src);
const char *const appname = "PSCP"; const char *const appname = "PSCP";
@ -67,7 +67,7 @@ static void tell_char(FILE * stream, char c)
fputc(c, stream); fputc(c, stream);
} }
static void tell_str(FILE * stream, char *str) static void tell_str(FILE *stream, const char *str)
{ {
unsigned int i; unsigned int i;
@ -75,7 +75,7 @@ static void tell_str(FILE * stream, char *str)
tell_char(stream, str[i]); tell_char(stream, str[i]);
} }
static void tell_user(FILE * stream, char *fmt, ...) static void tell_user(FILE *stream, const char *fmt, ...)
{ {
char *str, *str2; char *str, *str2;
va_list ap; va_list ap;
@ -91,7 +91,7 @@ static void tell_user(FILE * stream, char *fmt, ...)
/* /*
* Print an error message and perform a fatal exit. * Print an error message and perform a fatal exit.
*/ */
void fatalbox(char *fmt, ...) void fatalbox(const char *fmt, ...)
{ {
char *str, *str2; char *str, *str2;
va_list ap; va_list ap;
@ -106,7 +106,7 @@ void fatalbox(char *fmt, ...)
cleanup_exit(1); cleanup_exit(1);
} }
void modalfatalbox(char *fmt, ...) void modalfatalbox(const char *fmt, ...)
{ {
char *str, *str2; char *str, *str2;
va_list ap; va_list ap;
@ -121,7 +121,7 @@ void modalfatalbox(char *fmt, ...)
cleanup_exit(1); cleanup_exit(1);
} }
void nonfatal(char *fmt, ...) void nonfatal(const char *fmt, ...)
{ {
char *str, *str2; char *str, *str2;
va_list ap; va_list ap;
@ -134,7 +134,7 @@ void nonfatal(char *fmt, ...)
sfree(str2); sfree(str2);
errs++; errs++;
} }
void connection_fatal(void *frontend, char *fmt, ...) void connection_fatal(void *frontend, const char *fmt, ...)
{ {
char *str, *str2; char *str, *str2;
va_list ap; va_list ap;
@ -302,7 +302,7 @@ static void ssh_scp_init(void)
/* /*
* Print an error message and exit after closing the SSH link. * Print an error message and exit after closing the SSH link.
*/ */
static void bump(char *fmt, ...) static void bump(const char *fmt, ...)
{ {
char *str, *str2; char *str, *str2;
va_list ap; va_list ap;
@ -533,7 +533,7 @@ static void do_cmd(char *host, char *user, char *cmd)
/* /*
* Update statistic information about current file. * Update statistic information about current file.
*/ */
static void print_stats(char *name, uint64 size, uint64 done, static void print_stats(const char *name, uint64 size, uint64 done,
time_t start, time_t now) time_t start, time_t now)
{ {
float ratebs; float ratebs;
@ -608,8 +608,13 @@ static char *colon(char *str)
/* /*
* Return a pointer to the portion of str that comes after the last * Return a pointer to the portion of str that comes after the last
* slash (or backslash or colon, if `local' is TRUE). * slash (or backslash or colon, if `local' is TRUE).
*
* This function has the annoying strstr() property of taking a const
* char * and returning a char *. You should treat it as if it was a
* pair of overloaded functions, one mapping mutable->mutable and the
* other const->const :-(
*/ */
static char *stripslashes(char *str, int local) static char *stripslashes(const char *str, int local)
{ {
char *p; char *p;
@ -626,7 +631,7 @@ static char *stripslashes(char *str, int local)
if (p) str = p+1; if (p) str = p+1;
} }
return str; return (char *)str;
} }
/* /*
@ -692,7 +697,7 @@ static int sftp_ls_compare(const void *av, const void *bv)
const struct fxp_name *b = (const struct fxp_name *) bv; const struct fxp_name *b = (const struct fxp_name *) bv;
return strcmp(a->filename, b->filename); return strcmp(a->filename, b->filename);
} }
void scp_sftp_listdir(char *dirname) void scp_sftp_listdir(const char *dirname)
{ {
struct fxp_handle *dirh; struct fxp_handle *dirh;
struct fxp_names *names; struct fxp_names *names;
@ -791,7 +796,7 @@ static struct fxp_handle *scp_sftp_filehandle;
static struct fxp_xfer *scp_sftp_xfer; static struct fxp_xfer *scp_sftp_xfer;
static uint64 scp_sftp_fileoffset; static uint64 scp_sftp_fileoffset;
int scp_source_setup(char *target, int shouldbedir) int scp_source_setup(const char *target, int shouldbedir)
{ {
if (using_sftp) { if (using_sftp) {
/* /*
@ -857,7 +862,7 @@ int scp_send_filetimes(unsigned long mtime, unsigned long atime)
} }
} }
int scp_send_filename(char *name, uint64 size, int permissions) int scp_send_filename(const char *name, uint64 size, int permissions)
{ {
if (using_sftp) { if (using_sftp) {
char *fullname; char *fullname;
@ -1012,7 +1017,7 @@ void scp_restore_remotepath(char *data)
scp_sftp_remotepath = data; scp_sftp_remotepath = data;
} }
int scp_send_dirname(char *name, int modes) int scp_send_dirname(const char *name, int modes)
{ {
if (using_sftp) { if (using_sftp) {
char *fullname; char *fullname;
@ -1087,7 +1092,7 @@ int scp_send_enddir(void)
* right at the start, whereas scp_sink_init is called to * right at the start, whereas scp_sink_init is called to
* initialise every level of recursion in the protocol. * initialise every level of recursion in the protocol.
*/ */
int scp_sink_setup(char *source, int preserve, int recursive) int scp_sink_setup(const char *source, int preserve, int recursive)
{ {
if (using_sftp) { if (using_sftp) {
char *newsource; char *newsource;
@ -1657,12 +1662,12 @@ static void run_err(const char *fmt, ...)
/* /*
* Execute the source part of the SCP protocol. * Execute the source part of the SCP protocol.
*/ */
static void source(char *src) static void source(const char *src)
{ {
uint64 size; uint64 size;
unsigned long mtime, atime; unsigned long mtime, atime;
long permissions; long permissions;
char *last; const char *last;
RFile *f; RFile *f;
int attr; int attr;
uint64 i; uint64 i;
@ -1682,7 +1687,7 @@ static void source(char *src)
/* /*
* Avoid . and .. directories. * Avoid . and .. directories.
*/ */
char *p; const char *p;
p = strrchr(src, '/'); p = strrchr(src, '/');
if (!p) if (!p)
p = strrchr(src, '\\'); p = strrchr(src, '\\');
@ -1770,9 +1775,9 @@ static void source(char *src)
/* /*
* Recursively send the contents of a directory. * Recursively send the contents of a directory.
*/ */
static void rsource(char *src) static void rsource(const char *src)
{ {
char *last; const char *last;
char *save_target; char *save_target;
DirHandle *dir; DirHandle *dir;
@ -1814,7 +1819,7 @@ static void rsource(char *src)
/* /*
* Execute the sink part of the SCP protocol. * Execute the sink part of the SCP protocol.
*/ */
static void sink(char *targ, char *src) static void sink(const char *targ, const char *src)
{ {
char *destfname; char *destfname;
int targisdir = 0; int targisdir = 0;
@ -2020,23 +2025,26 @@ static void sink(char *targ, char *src)
*/ */
static void toremote(int argc, char *argv[]) static void toremote(int argc, char *argv[])
{ {
char *src, *targ, *host, *user; char *src, *wtarg, *host, *user;
const char *targ;
char *cmd; char *cmd;
int i, wc_type; int i, wc_type;
uploading = 1; uploading = 1;
targ = argv[argc - 1]; wtarg = argv[argc - 1];
/* Separate host from filename */ /* Separate host from filename */
host = targ; host = wtarg;
targ = colon(targ); wtarg = colon(wtarg);
if (targ == NULL) if (wtarg == NULL)
bump("targ == NULL in toremote()"); bump("wtarg == NULL in toremote()");
*targ++ = '\0'; *wtarg++ = '\0';
if (*targ == '\0')
targ = ".";
/* Substitute "." for empty target */ /* Substitute "." for empty target */
if (*wtarg == '\0')
targ = ".";
else
targ = wtarg;
/* Separate host and username */ /* Separate host and username */
user = host; user = host;
@ -2112,7 +2120,8 @@ static void toremote(int argc, char *argv[])
*/ */
static void tolocal(int argc, char *argv[]) static void tolocal(int argc, char *argv[])
{ {
char *src, *targ, *host, *user; char *wsrc, *host, *user;
const char *src, *targ;
char *cmd; char *cmd;
uploading = 0; uploading = 0;
@ -2120,18 +2129,20 @@ static void tolocal(int argc, char *argv[])
if (argc != 2) if (argc != 2)
bump("More than one remote source not supported"); bump("More than one remote source not supported");
src = argv[0]; wsrc = argv[0];
targ = argv[1]; targ = argv[1];
/* Separate host from filename */ /* Separate host from filename */
host = src; host = wsrc;
src = colon(src); wsrc = colon(wsrc);
if (src == NULL) if (wsrc == NULL)
bump("Local to local copy not supported"); bump("Local to local copy not supported");
*src++ = '\0'; *wsrc++ = '\0';
if (*src == '\0')
src = ".";
/* Substitute "." for empty filename */ /* Substitute "." for empty filename */
if (*wsrc == '\0')
src = ".";
else
src = wsrc;
/* Separate username and hostname */ /* Separate username and hostname */
user = host; user = host;
@ -2164,21 +2175,25 @@ static void tolocal(int argc, char *argv[])
*/ */
static void get_dir_list(int argc, char *argv[]) static void get_dir_list(int argc, char *argv[])
{ {
char *src, *host, *user; char *wsrc, *host, *user;
char *cmd, *p, *q; const char *src;
char *cmd, *p;
const char *q;
char c; char c;
src = argv[0]; wsrc = argv[0];
/* Separate host from filename */ /* Separate host from filename */
host = src; host = wsrc;
src = colon(src); wsrc = colon(wsrc);
if (src == NULL) if (wsrc == NULL)
bump("Local file listing not supported"); bump("Local file listing not supported");
*src++ = '\0'; *wsrc++ = '\0';
if (*src == '\0')
src = ".";
/* Substitute "." for empty filename */ /* Substitute "." for empty filename */
if (*wsrc == '\0')
src = ".";
else
src = wsrc;
/* Separate username and hostname */ /* Separate username and hostname */
user = host; user = host;
@ -2273,7 +2288,7 @@ void version(void)
cleanup_exit(1); cleanup_exit(1);
} }
void cmdline_error(char *p, ...) void cmdline_error(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "pscp: "); fprintf(stderr, "pscp: ");

34
psftp.c
View File

@ -68,7 +68,7 @@ struct sftp_packet *sftp_wait_for_reply(struct sftp_request *req)
* canonification fails, at least fall back to returning a _valid_ * canonification fails, at least fall back to returning a _valid_
* pathname (though it may be ugly, eg /home/simon/../foobar). * pathname (though it may be ugly, eg /home/simon/../foobar).
*/ */
char *canonify(char *name) char *canonify(const char *name)
{ {
char *fullname, *canonname; char *fullname, *canonname;
struct sftp_packet *pktin; struct sftp_packet *pktin;
@ -77,7 +77,7 @@ char *canonify(char *name)
if (name[0] == '/') { if (name[0] == '/') {
fullname = dupstr(name); fullname = dupstr(name);
} else { } else {
char *slash; const char *slash;
if (pwd[strlen(pwd) - 1] == '/') if (pwd[strlen(pwd) - 1] == '/')
slash = ""; slash = "";
else else
@ -172,8 +172,13 @@ char *canonify(char *name)
/* /*
* Return a pointer to the portion of str that comes after the last * Return a pointer to the portion of str that comes after the last
* slash (or backslash or colon, if `local' is TRUE). * slash (or backslash or colon, if `local' is TRUE).
*
* This function has the annoying strstr() property of taking a const
* char * and returning a char *. You should treat it as if it was a
* pair of overloaded functions, one mapping mutable->mutable and the
* other const->const :-(
*/ */
static char *stripslashes(char *str, int local) static char *stripslashes(const char *str, int local)
{ {
char *p; char *p;
@ -190,7 +195,7 @@ static char *stripslashes(char *str, int local)
if (p) str = p+1; if (p) str = p+1;
} }
return str; return (char *)str;
} }
/* /*
@ -1011,7 +1016,8 @@ int sftp_cmd_ls(struct sftp_command *cmd)
struct fxp_names *names; struct fxp_names *names;
struct fxp_name **ournames; struct fxp_name **ournames;
int nnames, namesize; int nnames, namesize;
char *dir, *cdir, *unwcdir, *wildcard; const char *dir;
char *cdir, *unwcdir, *wildcard;
struct sftp_packet *pktin; struct sftp_packet *pktin;
struct sftp_request *req; struct sftp_request *req;
int i; int i;
@ -1901,7 +1907,7 @@ static int sftp_cmd_pling(struct sftp_command *cmd)
static int sftp_cmd_help(struct sftp_command *cmd); static int sftp_cmd_help(struct sftp_command *cmd);
static struct sftp_cmd_lookup { static struct sftp_cmd_lookup {
char *name; const char *name;
/* /*
* For help purposes, there are two kinds of command: * For help purposes, there are two kinds of command:
* *
@ -1915,8 +1921,8 @@ static struct sftp_cmd_lookup {
* contains the help that should double up for this command. * contains the help that should double up for this command.
*/ */
int listed; /* do we list this in primary help? */ int listed; /* do we list this in primary help? */
char *shorthelp; const char *shorthelp;
char *longhelp; const char *longhelp;
int (*obey) (struct sftp_command *); int (*obey) (struct sftp_command *);
} sftp_lookup[] = { } sftp_lookup[] = {
/* /*
@ -2139,7 +2145,7 @@ static struct sftp_cmd_lookup {
} }
}; };
const struct sftp_cmd_lookup *lookup_command(char *name) const struct sftp_cmd_lookup *lookup_command(const char *name)
{ {
int i, j, k, cmp; int i, j, k, cmp;
@ -2450,7 +2456,7 @@ static int verbose = 0;
/* /*
* Print an error message and perform a fatal exit. * Print an error message and perform a fatal exit.
*/ */
void fatalbox(char *fmt, ...) void fatalbox(const char *fmt, ...)
{ {
char *str, *str2; char *str, *str2;
va_list ap; va_list ap;
@ -2464,7 +2470,7 @@ void fatalbox(char *fmt, ...)
cleanup_exit(1); cleanup_exit(1);
} }
void modalfatalbox(char *fmt, ...) void modalfatalbox(const char *fmt, ...)
{ {
char *str, *str2; char *str, *str2;
va_list ap; va_list ap;
@ -2478,7 +2484,7 @@ void modalfatalbox(char *fmt, ...)
cleanup_exit(1); cleanup_exit(1);
} }
void nonfatal(char *fmt, ...) void nonfatal(const char *fmt, ...)
{ {
char *str, *str2; char *str, *str2;
va_list ap; va_list ap;
@ -2490,7 +2496,7 @@ void nonfatal(char *fmt, ...)
fputs(str2, stderr); fputs(str2, stderr);
sfree(str2); sfree(str2);
} }
void connection_fatal(void *frontend, char *fmt, ...) void connection_fatal(void *frontend, const char *fmt, ...)
{ {
char *str, *str2; char *str, *str2;
va_list ap; va_list ap;
@ -2866,7 +2872,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
return 0; return 0;
} }
void cmdline_error(char *p, ...) void cmdline_error(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "psftp: "); fprintf(stderr, "psftp: ");

26
psftp.h
View File

@ -45,7 +45,7 @@ int ssh_sftp_loop_iteration(void);
* FALSE, a back end is not (intentionally) active at all (e.g. * FALSE, a back end is not (intentionally) active at all (e.g.
* psftp before an `open' command). * psftp before an `open' command).
*/ */
char *ssh_sftp_get_cmdline(char *prompt, int backend_required); char *ssh_sftp_get_cmdline(const char *prompt, int backend_required);
/* /*
* The main program in psftp.c. Called from main() in the platform- * The main program in psftp.c. Called from main() in the platform-
@ -59,13 +59,13 @@ int psftp_main(int argc, char *argv[]);
* probably only ever be supported on Windows, so these functions * probably only ever be supported on Windows, so these functions
* can safely be stubs on all other platforms. * can safely be stubs on all other platforms.
*/ */
void gui_update_stats(char *name, unsigned long size, void gui_update_stats(const char *name, unsigned long size,
int percentage, unsigned long elapsed, int percentage, unsigned long elapsed,
unsigned long done, unsigned long eta, unsigned long done, unsigned long eta,
unsigned long ratebs); unsigned long ratebs);
void gui_send_errcount(int list, int errs); void gui_send_errcount(int list, int errs);
void gui_send_char(int is_stderr, int c); void gui_send_char(int is_stderr, int c);
void gui_enable(char *arg); void gui_enable(const char *arg);
/* /*
* It's likely that a given platform's implementation of file * It's likely that a given platform's implementation of file
@ -87,15 +87,15 @@ typedef struct RFile RFile;
typedef struct WFile WFile; typedef struct WFile WFile;
/* Output params size, perms, mtime and atime can all be NULL if /* Output params size, perms, mtime and atime can all be NULL if
* desired. perms will be -1 if the OS does not support POSIX permissions. */ * desired. perms will be -1 if the OS does not support POSIX permissions. */
RFile *open_existing_file(char *name, uint64 *size, RFile *open_existing_file(const char *name, uint64 *size,
unsigned long *mtime, unsigned long *atime, unsigned long *mtime, unsigned long *atime,
long *perms); long *perms);
WFile *open_existing_wfile(char *name, uint64 *size); WFile *open_existing_wfile(const char *name, uint64 *size);
/* Returns <0 on error, 0 on eof, or number of bytes read, as usual */ /* Returns <0 on error, 0 on eof, or number of bytes read, as usual */
int read_from_file(RFile *f, void *buffer, int length); int read_from_file(RFile *f, void *buffer, int length);
/* Closes and frees the RFile */ /* Closes and frees the RFile */
void close_rfile(RFile *f); void close_rfile(RFile *f);
WFile *open_new_file(char *name, long perms); WFile *open_new_file(const char *name, long perms);
/* Returns <0 on error, 0 on eof, or number of bytes written, as usual */ /* Returns <0 on error, 0 on eof, or number of bytes written, as usual */
int write_to_file(WFile *f, void *buffer, int length); int write_to_file(WFile *f, void *buffer, int length);
void set_file_times(WFile *f, unsigned long mtime, unsigned long atime); void set_file_times(WFile *f, unsigned long mtime, unsigned long atime);
@ -117,13 +117,13 @@ uint64 get_file_posn(WFile *f);
enum { enum {
FILE_TYPE_NONEXISTENT, FILE_TYPE_FILE, FILE_TYPE_DIRECTORY, FILE_TYPE_WEIRD FILE_TYPE_NONEXISTENT, FILE_TYPE_FILE, FILE_TYPE_DIRECTORY, FILE_TYPE_WEIRD
}; };
int file_type(char *name); int file_type(const char *name);
/* /*
* Read all the file names out of a directory. * Read all the file names out of a directory.
*/ */
typedef struct DirHandle DirHandle; typedef struct DirHandle DirHandle;
DirHandle *open_directory(char *name); DirHandle *open_directory(const char *name);
/* The string returned from this will need freeing if not NULL */ /* The string returned from this will need freeing if not NULL */
char *read_filename(DirHandle *dir); char *read_filename(DirHandle *dir);
void close_directory(DirHandle *dir); void close_directory(DirHandle *dir);
@ -145,13 +145,13 @@ void close_directory(DirHandle *dir);
enum { enum {
WCTYPE_NONEXISTENT, WCTYPE_FILENAME, WCTYPE_WILDCARD WCTYPE_NONEXISTENT, WCTYPE_FILENAME, WCTYPE_WILDCARD
}; };
int test_wildcard(char *name, int cmdline); int test_wildcard(const char *name, int cmdline);
/* /*
* Actually return matching file names for a local wildcard. * Actually return matching file names for a local wildcard.
*/ */
typedef struct WildcardMatcher WildcardMatcher; typedef struct WildcardMatcher WildcardMatcher;
WildcardMatcher *begin_wildcard_matching(char *name); WildcardMatcher *begin_wildcard_matching(const char *name);
/* The string returned from this will need freeing if not NULL */ /* The string returned from this will need freeing if not NULL */
char *wildcard_get_filename(WildcardMatcher *dir); char *wildcard_get_filename(WildcardMatcher *dir);
void finish_wildcard_matching(WildcardMatcher *dir); void finish_wildcard_matching(WildcardMatcher *dir);
@ -164,17 +164,17 @@ void finish_wildcard_matching(WildcardMatcher *dir);
* *
* Returns TRUE if the filename is kosher, FALSE if dangerous. * Returns TRUE if the filename is kosher, FALSE if dangerous.
*/ */
int vet_filename(char *name); int vet_filename(const char *name);
/* /*
* Create a directory. Returns 0 on error, !=0 on success. * Create a directory. Returns 0 on error, !=0 on success.
*/ */
int create_directory(char *name); int create_directory(const char *name);
/* /*
* Concatenate a directory name and a file name. The way this is * Concatenate a directory name and a file name. The way this is
* done will depend on the OS. * done will depend on the OS.
*/ */
char *dir_file_cat(char *dir, char *file); char *dir_file_cat(const char *dir, const char *file);
#endif /* PUTTY_PSFTP_H */ #endif /* PUTTY_PSFTP_H */

55
putty.h
View File

@ -139,7 +139,7 @@ typedef struct terminal_tag Terminal;
struct sesslist { struct sesslist {
int nsessions; int nsessions;
char **sessions; const char **sessions;
char *buffer; /* so memory can be freed later */ char *buffer; /* so memory can be freed later */
}; };
@ -359,7 +359,7 @@ struct keyvalwhere {
* Two fields which define a string and enum value to be * Two fields which define a string and enum value to be
* equivalent to each other. * equivalent to each other.
*/ */
char *s; const char *s;
int v; int v;
/* /*
@ -416,13 +416,13 @@ enum {
struct backend_tag { struct backend_tag {
const char *(*init) (void *frontend_handle, void **backend_handle, const char *(*init) (void *frontend_handle, void **backend_handle,
Conf *conf, char *host, int port, char **realhost, Conf *conf, const char *host, int port,
int nodelay, int keepalive); char **realhost, int nodelay, int keepalive);
void (*free) (void *handle); void (*free) (void *handle);
/* back->reconfig() passes in a replacement configuration. */ /* back->reconfig() passes in a replacement configuration. */
void (*reconfig) (void *handle, Conf *conf); void (*reconfig) (void *handle, Conf *conf);
/* back->send() returns the current amount of buffered data. */ /* back->send() returns the current amount of buffered data. */
int (*send) (void *handle, char *buf, int len); int (*send) (void *handle, const char *buf, int len);
/* back->sendbuffer() does the same thing but without attempting a send */ /* back->sendbuffer() does the same thing but without attempting a send */
int (*sendbuffer) (void *handle); int (*sendbuffer) (void *handle);
void (*size) (void *handle, int width, int height); void (*size) (void *handle, int width, int height);
@ -442,7 +442,7 @@ struct backend_tag {
*/ */
void (*unthrottle) (void *handle, int); void (*unthrottle) (void *handle, int);
int (*cfg_info) (void *handle); int (*cfg_info) (void *handle);
char *name; const char *name;
int protocol; int protocol;
int default_port; int default_port;
}; };
@ -589,10 +589,10 @@ void write_clip(void *frontend, wchar_t *, int *, int, int);
void get_clip(void *frontend, wchar_t **, int *); void get_clip(void *frontend, wchar_t **, int *);
void optimised_move(void *frontend, int, int, int); void optimised_move(void *frontend, int, int, int);
void set_raw_mouse_mode(void *frontend, int); void set_raw_mouse_mode(void *frontend, int);
void connection_fatal(void *frontend, char *, ...); void connection_fatal(void *frontend, const char *, ...);
void nonfatal(char *, ...); void nonfatal(const char *, ...);
void fatalbox(char *, ...); void fatalbox(const char *, ...);
void modalfatalbox(char *, ...); void modalfatalbox(const char *, ...);
#ifdef macintosh #ifdef macintosh
#pragma noreturn(fatalbox) #pragma noreturn(fatalbox)
#pragma noreturn(modalfatalbox) #pragma noreturn(modalfatalbox)
@ -624,7 +624,7 @@ char *get_ttymode(void *frontend, const char *mode);
* 0 = `user cancelled' (FIXME distinguish "give up entirely" and "next auth"?) * 0 = `user cancelled' (FIXME distinguish "give up entirely" and "next auth"?)
* <0 = `please call back later with more in/inlen' * <0 = `please call back later with more in/inlen'
*/ */
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen); int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen);
#define OPTIMISE_IS_SCROLL 1 #define OPTIMISE_IS_SCROLL 1
void set_iconic(void *frontend, int iconic); void set_iconic(void *frontend, int iconic);
@ -940,12 +940,12 @@ void random_destroy_seed(void);
Backend *backend_from_name(const char *name); Backend *backend_from_name(const char *name);
Backend *backend_from_proto(int proto); Backend *backend_from_proto(int proto);
char *get_remote_username(Conf *conf); /* dynamically allocated */ char *get_remote_username(Conf *conf); /* dynamically allocated */
char *save_settings(char *section, Conf *conf); char *save_settings(const char *section, Conf *conf);
void save_open_settings(void *sesskey, Conf *conf); void save_open_settings(void *sesskey, Conf *conf);
void load_settings(char *section, Conf *conf); void load_settings(const char *section, Conf *conf);
void load_open_settings(void *sesskey, Conf *conf); void load_open_settings(void *sesskey, Conf *conf);
void get_sesslist(struct sesslist *, int allocate); void get_sesslist(struct sesslist *, int allocate);
void do_defaults(char *, Conf *); void do_defaults(const char *, Conf *);
void registry_cleanup(void); void registry_cleanup(void);
/* /*
@ -1003,7 +1003,7 @@ void term_provide_logctx(Terminal *term, void *logctx);
void term_set_focus(Terminal *term, int has_focus); void term_set_focus(Terminal *term, int has_focus);
char *term_get_ttymode(Terminal *term, const char *mode); char *term_get_ttymode(Terminal *term, const char *mode);
int term_get_userpass_input(Terminal *term, prompts_t *p, int term_get_userpass_input(Terminal *term, prompts_t *p,
unsigned char *in, int inlen); const unsigned char *in, int inlen);
int format_arrow_key(char *buf, Terminal *term, int xkey, int ctrl); int format_arrow_key(char *buf, Terminal *term, int xkey, int ctrl);
@ -1026,7 +1026,7 @@ struct logblank_t {
int type; int type;
}; };
void log_packet(void *logctx, int direction, int type, void log_packet(void *logctx, int direction, int type,
char *texttype, const void *data, int len, const char *texttype, const void *data, int len,
int n_blanks, const struct logblank_t *blanks, int n_blanks, const struct logblank_t *blanks,
const unsigned long *sequence, const unsigned long *sequence,
unsigned downstream_id, const char *additional_log_text); unsigned downstream_id, const char *additional_log_text);
@ -1067,14 +1067,15 @@ extern Backend ssh_backend;
void *ldisc_create(Conf *, Terminal *, Backend *, void *, void *); void *ldisc_create(Conf *, Terminal *, Backend *, void *, void *);
void ldisc_configure(void *, Conf *); void ldisc_configure(void *, Conf *);
void ldisc_free(void *); void ldisc_free(void *);
void ldisc_send(void *handle, char *buf, int len, int interactive); void ldisc_send(void *handle, const char *buf, int len, int interactive);
void ldisc_echoedit_update(void *handle); void ldisc_echoedit_update(void *handle);
/* /*
* Exports from ldiscucs.c. * Exports from ldiscucs.c.
*/ */
void lpage_send(void *, int codepage, char *buf, int len, int interactive); void lpage_send(void *, int codepage, const char *buf, int len,
void luni_send(void *, wchar_t * widebuf, int len, int interactive); int interactive);
void luni_send(void *, const wchar_t * widebuf, int len, int interactive);
/* /*
* Exports from sshrand.c. * Exports from sshrand.c.
@ -1128,7 +1129,7 @@ int is_dbcs_leadbyte(int codepage, char byte);
int mb_to_wc(int codepage, int flags, const char *mbstr, int mblen, int mb_to_wc(int codepage, int flags, const char *mbstr, int mblen,
wchar_t *wcstr, int wclen); wchar_t *wcstr, int wclen);
int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen, int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
char *mbstr, int mblen, char *defchr, int *defused, char *mbstr, int mblen, const char *defchr, int *defused,
struct unicode_data *ucsdata); struct unicode_data *ucsdata);
wchar_t xlat_uskbd2cyrllic(int ch); wchar_t xlat_uskbd2cyrllic(int ch);
int check_compose(int first, int second); int check_compose(int first, int second);
@ -1217,7 +1218,8 @@ int askappend(void *frontend, Filename *filename,
* that aren't equivalents to things in windlg.c et al. * that aren't equivalents to things in windlg.c et al.
*/ */
extern int console_batch_mode; extern int console_batch_mode;
int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen); int console_get_userpass_input(prompts_t *p, const unsigned char *in,
int inlen);
void console_provide_logctx(void *logctx); void console_provide_logctx(void *logctx);
int is_interactive(void); int is_interactive(void);
@ -1237,16 +1239,21 @@ void printer_finish_job(printer_job *);
* Exports from cmdline.c (and also cmdline_error(), which is * Exports from cmdline.c (and also cmdline_error(), which is
* defined differently in various places and required _by_ * defined differently in various places and required _by_
* cmdline.c). * cmdline.c).
*
* Note that cmdline_process_param takes a const option string, but a
* writable argument string. That's not a mistake - that's so it can
* zero out password arguments in the hope of not having them show up
* avoidably in Unix 'ps'.
*/ */
int cmdline_process_param(char *, char *, int, Conf *); int cmdline_process_param(const char *, char *, int, Conf *);
void cmdline_run_saved(Conf *); void cmdline_run_saved(Conf *);
void cmdline_cleanup(void); void cmdline_cleanup(void);
int cmdline_get_passwd_input(prompts_t *p, unsigned char *in, int inlen); int cmdline_get_passwd_input(prompts_t *p, const unsigned char *in, int inlen);
#define TOOLTYPE_FILETRANSFER 1 #define TOOLTYPE_FILETRANSFER 1
#define TOOLTYPE_NONNETWORK 2 #define TOOLTYPE_NONNETWORK 2
extern int cmdline_tooltype; extern int cmdline_tooltype;
void cmdline_error(char *, ...); void cmdline_error(const char *, ...);
/* /*
* Exports from config.c. * Exports from config.c.

6
raw.c
View File

@ -125,8 +125,8 @@ static void raw_sent(Plug plug, int bufsize)
*/ */
static const char *raw_init(void *frontend_handle, void **backend_handle, static const char *raw_init(void *frontend_handle, void **backend_handle,
Conf *conf, Conf *conf,
char *host, int port, char **realhost, int nodelay, const char *host, int port, char **realhost,
int keepalive) int nodelay, int keepalive)
{ {
static const struct plug_function_table fn_table = { static const struct plug_function_table fn_table = {
raw_log, raw_log,
@ -214,7 +214,7 @@ static void raw_reconfig(void *handle, Conf *conf)
/* /*
* Called to send data down the raw connection. * Called to send data down the raw connection.
*/ */
static int raw_send(void *handle, char *buf, int len) static int raw_send(void *handle, const char *buf, int len)
{ {
Raw raw = (Raw) handle; Raw raw = (Raw) handle;

View File

@ -161,7 +161,7 @@ static void rlogin_startup(Rlogin rlogin, const char *ruser)
*/ */
static const char *rlogin_init(void *frontend_handle, void **backend_handle, static const char *rlogin_init(void *frontend_handle, void **backend_handle,
Conf *conf, Conf *conf,
char *host, int port, char **realhost, const char *host, int port, char **realhost,
int nodelay, int keepalive) int nodelay, int keepalive)
{ {
static const struct plug_function_table fn_table = { static const struct plug_function_table fn_table = {
@ -279,7 +279,7 @@ static void rlogin_reconfig(void *handle, Conf *conf)
/* /*
* Called to send data down the rlogin connection. * Called to send data down the rlogin connection.
*/ */
static int rlogin_send(void *handle, char *buf, int len) static int rlogin_send(void *handle, const char *buf, int len)
{ {
Rlogin rlogin = (Rlogin) handle; Rlogin rlogin = (Rlogin) handle;

View File

@ -124,13 +124,14 @@ static void gppfile(void *handle, const char *name, Conf *conf, int primary)
filename_free(result); filename_free(result);
} }
static int gppi_raw(void *handle, char *name, int def) static int gppi_raw(void *handle, const char *name, int def)
{ {
def = platform_default_i(name, def); def = platform_default_i(name, def);
return read_setting_i(handle, name, def); return read_setting_i(handle, name, def);
} }
static void gppi(void *handle, char *name, int def, Conf *conf, int primary) static void gppi(void *handle, const char *name, int def,
Conf *conf, int primary)
{ {
conf_set_int(conf, primary, gppi_raw(handle, name, def)); conf_set_int(conf, primary, gppi_raw(handle, name, def));
} }
@ -142,7 +143,7 @@ static void gppi(void *handle, char *name, int def, Conf *conf, int primary)
* If there's no "=VALUE" (e.g. just NAME,NAME,NAME) then those keys * If there's no "=VALUE" (e.g. just NAME,NAME,NAME) then those keys
* are mapped to the empty string. * are mapped to the empty string.
*/ */
static int gppmap(void *handle, char *name, Conf *conf, int primary) static int gppmap(void *handle, const char *name, Conf *conf, int primary)
{ {
char *buf, *p, *q, *key, *val; char *buf, *p, *q, *key, *val;
@ -212,7 +213,8 @@ static int gppmap(void *handle, char *name, Conf *conf, int primary)
static void wmap(void *handle, char const *outkey, Conf *conf, int primary, static void wmap(void *handle, char const *outkey, Conf *conf, int primary,
int include_values) int include_values)
{ {
char *buf, *p, *q, *key, *realkey, *val; char *buf, *p, *key, *realkey;
const char *val, *q;
int len; int len;
len = 1; /* allow for NUL */ len = 1; /* allow for NUL */
@ -298,7 +300,7 @@ static const char *val2key(const struct keyvalwhere *mapping,
* to the end and duplicates are weeded. * to the end and duplicates are weeded.
* XXX: assumes vals in 'mapping' are small +ve integers * XXX: assumes vals in 'mapping' are small +ve integers
*/ */
static void gprefs(void *sesskey, char *name, char *def, static void gprefs(void *sesskey, const char *name, const char *def,
const struct keyvalwhere *mapping, int nvals, const struct keyvalwhere *mapping, int nvals,
Conf *conf, int primary) Conf *conf, int primary)
{ {
@ -384,7 +386,7 @@ static void gprefs(void *sesskey, char *name, char *def,
/* /*
* Write out a preference list. * Write out a preference list.
*/ */
static void wprefs(void *sesskey, char *name, static void wprefs(void *sesskey, const char *name,
const struct keyvalwhere *mapping, int nvals, const struct keyvalwhere *mapping, int nvals,
Conf *conf, int primary) Conf *conf, int primary)
{ {
@ -418,7 +420,7 @@ static void wprefs(void *sesskey, char *name,
sfree(buf); sfree(buf);
} }
char *save_settings(char *section, Conf *conf) char *save_settings(const char *section, Conf *conf)
{ {
void *sesskey; void *sesskey;
char *errmsg; char *errmsg;
@ -434,7 +436,7 @@ char *save_settings(char *section, Conf *conf)
void save_open_settings(void *sesskey, Conf *conf) void save_open_settings(void *sesskey, Conf *conf)
{ {
int i; int i;
char *p; const char *p;
write_setting_i(sesskey, "Present", 1); write_setting_i(sesskey, "Present", 1);
write_setting_s(sesskey, "HostName", conf_get_str(conf, CONF_host)); write_setting_s(sesskey, "HostName", conf_get_str(conf, CONF_host));
@ -655,7 +657,7 @@ void save_open_settings(void *sesskey, Conf *conf)
wmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys, FALSE); wmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys, FALSE);
} }
void load_settings(char *section, Conf *conf) void load_settings(const char *section, Conf *conf)
{ {
void *sesskey; void *sesskey;
@ -769,7 +771,7 @@ void load_open_settings(void *sesskey, Conf *conf)
* disable gex under the "bugs" panel after one report of * disable gex under the "bugs" panel after one report of
* a server which offered it then choked, but we never got * a server which offered it then choked, but we never got
* a server version string or any other reports. */ * a server version string or any other reports. */
char *default_kexes; const char *default_kexes;
i = 2 - gppi_raw(sesskey, "BugDHGEx2", 0); i = 2 - gppi_raw(sesskey, "BugDHGEx2", 0);
if (i == FORCE_ON) if (i == FORCE_ON)
default_kexes = "ecdh,dh-group14-sha1,dh-group1-sha1,rsa," default_kexes = "ecdh,dh-group14-sha1,dh-group1-sha1,rsa,"
@ -1006,7 +1008,7 @@ void load_open_settings(void *sesskey, Conf *conf)
gppmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys); gppmap(sesskey, "SSHManualHostKeys", conf, CONF_ssh_manual_hostkeys);
} }
void do_defaults(char *session, Conf *conf) void do_defaults(const char *session, Conf *conf)
{ {
load_settings(session, conf); load_settings(session, conf);
} }
@ -1076,7 +1078,7 @@ void get_sesslist(struct sesslist *list, int allocate)
p++; p++;
} }
list->sessions = snewn(list->nsessions + 1, char *); list->sessions = snewn(list->nsessions + 1, const char *);
list->sessions[0] = "Default Settings"; list->sessions[0] = "Default Settings";
p = list->buffer; p = list->buffer;
i = 1; i = 1;
@ -1088,7 +1090,7 @@ void get_sesslist(struct sesslist *list, int allocate)
p++; p++;
} }
qsort(list->sessions, i, sizeof(char *), sessioncmp); qsort(list->sessions, i, sizeof(const char *), sessioncmp);
} else { } else {
sfree(list->buffer); sfree(list->buffer);
sfree(list->sessions); sfree(list->sessions);

33
sftp.c
View File

@ -23,7 +23,7 @@ struct sftp_packet {
static const char *fxp_error_message; static const char *fxp_error_message;
static int fxp_errtype; static int fxp_errtype;
static void fxp_internal_error(char *msg); static void fxp_internal_error(const char *msg);
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
* SFTP packet construction functions. * SFTP packet construction functions.
@ -35,7 +35,8 @@ static void sftp_pkt_ensure(struct sftp_packet *pkt, int length)
pkt->data = sresize(pkt->data, pkt->maxlen, char); pkt->data = sresize(pkt->data, pkt->maxlen, char);
} }
} }
static void sftp_pkt_adddata(struct sftp_packet *pkt, void *data, int len) static void sftp_pkt_adddata(struct sftp_packet *pkt,
const void *data, int len)
{ {
pkt->length += len; pkt->length += len;
sftp_pkt_ensure(pkt, pkt->length); sftp_pkt_ensure(pkt, pkt->length);
@ -82,18 +83,18 @@ static void sftp_pkt_addstring_start(struct sftp_packet *pkt)
sftp_pkt_adduint32(pkt, 0); sftp_pkt_adduint32(pkt, 0);
pkt->savedpos = pkt->length; pkt->savedpos = pkt->length;
} }
static void sftp_pkt_addstring_str(struct sftp_packet *pkt, char *data) static void sftp_pkt_addstring_str(struct sftp_packet *pkt, const char *data)
{ {
sftp_pkt_adddata(pkt, data, strlen(data)); sftp_pkt_adddata(pkt, data, strlen(data));
PUT_32BIT(pkt->data + pkt->savedpos - 4, pkt->length - pkt->savedpos); PUT_32BIT(pkt->data + pkt->savedpos - 4, pkt->length - pkt->savedpos);
} }
static void sftp_pkt_addstring_data(struct sftp_packet *pkt, static void sftp_pkt_addstring_data(struct sftp_packet *pkt,
char *data, int len) const char *data, int len)
{ {
sftp_pkt_adddata(pkt, data, len); sftp_pkt_adddata(pkt, data, len);
PUT_32BIT(pkt->data + pkt->savedpos - 4, pkt->length - pkt->savedpos); PUT_32BIT(pkt->data + pkt->savedpos - 4, pkt->length - pkt->savedpos);
} }
static void sftp_pkt_addstring(struct sftp_packet *pkt, char *data) static void sftp_pkt_addstring(struct sftp_packet *pkt, const char *data)
{ {
sftp_pkt_addstring_start(pkt); sftp_pkt_addstring_start(pkt);
sftp_pkt_addstring_str(pkt, data); sftp_pkt_addstring_str(pkt, data);
@ -438,7 +439,7 @@ static int fxp_got_status(struct sftp_packet *pktin)
return -1; return -1;
} }
static void fxp_internal_error(char *msg) static void fxp_internal_error(const char *msg)
{ {
fxp_error_message = msg; fxp_error_message = msg;
fxp_errtype = -1; fxp_errtype = -1;
@ -501,7 +502,7 @@ int fxp_init(void)
/* /*
* Canonify a pathname. * Canonify a pathname.
*/ */
struct sftp_request *fxp_realpath_send(char *path) struct sftp_request *fxp_realpath_send(const char *path)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout; struct sftp_packet *pktout;
@ -547,7 +548,7 @@ char *fxp_realpath_recv(struct sftp_packet *pktin, struct sftp_request *req)
/* /*
* Open a file. * Open a file.
*/ */
struct sftp_request *fxp_open_send(char *path, int type, struct sftp_request *fxp_open_send(const char *path, int type,
struct fxp_attrs *attrs) struct fxp_attrs *attrs)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
@ -596,7 +597,7 @@ struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin,
/* /*
* Open a directory. * Open a directory.
*/ */
struct sftp_request *fxp_opendir_send(char *path) struct sftp_request *fxp_opendir_send(const char *path)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout; struct sftp_packet *pktout;
@ -662,7 +663,7 @@ void fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req)
sftp_pkt_free(pktin); sftp_pkt_free(pktin);
} }
struct sftp_request *fxp_mkdir_send(char *path) struct sftp_request *fxp_mkdir_send(const char *path)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout; struct sftp_packet *pktout;
@ -688,7 +689,7 @@ int fxp_mkdir_recv(struct sftp_packet *pktin, struct sftp_request *req)
return 1; return 1;
} }
struct sftp_request *fxp_rmdir_send(char *path) struct sftp_request *fxp_rmdir_send(const char *path)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout; struct sftp_packet *pktout;
@ -713,7 +714,7 @@ int fxp_rmdir_recv(struct sftp_packet *pktin, struct sftp_request *req)
return 1; return 1;
} }
struct sftp_request *fxp_remove_send(char *fname) struct sftp_request *fxp_remove_send(const char *fname)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout; struct sftp_packet *pktout;
@ -738,7 +739,8 @@ int fxp_remove_recv(struct sftp_packet *pktin, struct sftp_request *req)
return 1; return 1;
} }
struct sftp_request *fxp_rename_send(char *srcfname, char *dstfname) struct sftp_request *fxp_rename_send(const char *srcfname,
const char *dstfname)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout; struct sftp_packet *pktout;
@ -768,7 +770,7 @@ int fxp_rename_recv(struct sftp_packet *pktin, struct sftp_request *req)
* Retrieve the attributes of a file. We have fxp_stat which works * Retrieve the attributes of a file. We have fxp_stat which works
* on filenames, and fxp_fstat which works on open file handles. * on filenames, and fxp_fstat which works on open file handles.
*/ */
struct sftp_request *fxp_stat_send(char *fname) struct sftp_request *fxp_stat_send(const char *fname)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout; struct sftp_packet *pktout;
@ -836,7 +838,8 @@ int fxp_fstat_recv(struct sftp_packet *pktin, struct sftp_request *req,
/* /*
* Set the attributes of a file. * Set the attributes of a file.
*/ */
struct sftp_request *fxp_setstat_send(char *fname, struct fxp_attrs attrs) struct sftp_request *fxp_setstat_send(const char *fname,
struct fxp_attrs attrs)
{ {
struct sftp_request *req = sftp_alloc_request(); struct sftp_request *req = sftp_alloc_request();
struct sftp_packet *pktout; struct sftp_packet *pktout;

20
sftp.h
View File

@ -125,14 +125,14 @@ int fxp_init(void);
* Canonify a pathname. Concatenate the two given path elements * Canonify a pathname. Concatenate the two given path elements
* with a separating slash, unless the second is NULL. * with a separating slash, unless the second is NULL.
*/ */
struct sftp_request *fxp_realpath_send(char *path); struct sftp_request *fxp_realpath_send(const char *path);
char *fxp_realpath_recv(struct sftp_packet *pktin, struct sftp_request *req); char *fxp_realpath_recv(struct sftp_packet *pktin, struct sftp_request *req);
/* /*
* Open a file. 'attrs' contains attributes to be applied to the file * Open a file. 'attrs' contains attributes to be applied to the file
* if it's being created. * if it's being created.
*/ */
struct sftp_request *fxp_open_send(char *path, int type, struct sftp_request *fxp_open_send(const char *path, int type,
struct fxp_attrs *attrs); struct fxp_attrs *attrs);
struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin, struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin,
struct sftp_request *req); struct sftp_request *req);
@ -140,7 +140,7 @@ struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin,
/* /*
* Open a directory. * Open a directory.
*/ */
struct sftp_request *fxp_opendir_send(char *path); struct sftp_request *fxp_opendir_send(const char *path);
struct fxp_handle *fxp_opendir_recv(struct sftp_packet *pktin, struct fxp_handle *fxp_opendir_recv(struct sftp_packet *pktin,
struct sftp_request *req); struct sftp_request *req);
@ -153,31 +153,32 @@ void fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req);
/* /*
* Make a directory. * Make a directory.
*/ */
struct sftp_request *fxp_mkdir_send(char *path); struct sftp_request *fxp_mkdir_send(const char *path);
int fxp_mkdir_recv(struct sftp_packet *pktin, struct sftp_request *req); int fxp_mkdir_recv(struct sftp_packet *pktin, struct sftp_request *req);
/* /*
* Remove a directory. * Remove a directory.
*/ */
struct sftp_request *fxp_rmdir_send(char *path); struct sftp_request *fxp_rmdir_send(const char *path);
int fxp_rmdir_recv(struct sftp_packet *pktin, struct sftp_request *req); int fxp_rmdir_recv(struct sftp_packet *pktin, struct sftp_request *req);
/* /*
* Remove a file. * Remove a file.
*/ */
struct sftp_request *fxp_remove_send(char *fname); struct sftp_request *fxp_remove_send(const char *fname);
int fxp_remove_recv(struct sftp_packet *pktin, struct sftp_request *req); int fxp_remove_recv(struct sftp_packet *pktin, struct sftp_request *req);
/* /*
* Rename a file. * Rename a file.
*/ */
struct sftp_request *fxp_rename_send(char *srcfname, char *dstfname); struct sftp_request *fxp_rename_send(const char *srcfname,
const char *dstfname);
int fxp_rename_recv(struct sftp_packet *pktin, struct sftp_request *req); int fxp_rename_recv(struct sftp_packet *pktin, struct sftp_request *req);
/* /*
* Return file attributes. * Return file attributes.
*/ */
struct sftp_request *fxp_stat_send(char *fname); struct sftp_request *fxp_stat_send(const char *fname);
int fxp_stat_recv(struct sftp_packet *pktin, struct sftp_request *req, int fxp_stat_recv(struct sftp_packet *pktin, struct sftp_request *req,
struct fxp_attrs *attrs); struct fxp_attrs *attrs);
struct sftp_request *fxp_fstat_send(struct fxp_handle *handle); struct sftp_request *fxp_fstat_send(struct fxp_handle *handle);
@ -187,7 +188,8 @@ int fxp_fstat_recv(struct sftp_packet *pktin, struct sftp_request *req,
/* /*
* Set file attributes. * Set file attributes.
*/ */
struct sftp_request *fxp_setstat_send(char *fname, struct fxp_attrs attrs); struct sftp_request *fxp_setstat_send(const char *fname,
struct fxp_attrs attrs);
int fxp_setstat_recv(struct sftp_packet *pktin, struct sftp_request *req); int fxp_setstat_recv(struct sftp_packet *pktin, struct sftp_request *req);
struct sftp_request *fxp_fsetstat_send(struct fxp_handle *handle, struct sftp_request *fxp_fsetstat_send(struct fxp_handle *handle,
struct fxp_attrs attrs); struct fxp_attrs attrs);

118
ssh.c
View File

@ -189,7 +189,7 @@ static unsigned int ssh_tty_parse_boolean(char *s)
#define translate(x) if (type == x) return #x #define translate(x) if (type == x) return #x
#define translatek(x,ctx) if (type == x && (pkt_kctx == ctx)) return #x #define translatek(x,ctx) if (type == x && (pkt_kctx == ctx)) return #x
#define translatea(x,ctx) if (type == x && (pkt_actx == ctx)) return #x #define translatea(x,ctx) if (type == x && (pkt_actx == ctx)) return #x
static char *ssh1_pkt_type(int type) static const char *ssh1_pkt_type(int type)
{ {
translate(SSH1_MSG_DISCONNECT); translate(SSH1_MSG_DISCONNECT);
translate(SSH1_SMSG_PUBLIC_KEY); translate(SSH1_SMSG_PUBLIC_KEY);
@ -234,7 +234,8 @@ static char *ssh1_pkt_type(int type)
translate(SSH1_CMSG_AUTH_CCARD_RESPONSE); translate(SSH1_CMSG_AUTH_CCARD_RESPONSE);
return "unknown"; return "unknown";
} }
static char *ssh2_pkt_type(Pkt_KCtx pkt_kctx, Pkt_ACtx pkt_actx, int type) static const char *ssh2_pkt_type(Pkt_KCtx pkt_kctx, Pkt_ACtx pkt_actx,
int type)
{ {
translatea(SSH2_MSG_USERAUTH_GSSAPI_RESPONSE,SSH2_PKTCTX_GSSAPI); translatea(SSH2_MSG_USERAUTH_GSSAPI_RESPONSE,SSH2_PKTCTX_GSSAPI);
translatea(SSH2_MSG_USERAUTH_GSSAPI_TOKEN,SSH2_PKTCTX_GSSAPI); translatea(SSH2_MSG_USERAUTH_GSSAPI_TOKEN,SSH2_PKTCTX_GSSAPI);
@ -357,9 +358,9 @@ static void ssh2_pkt_addmp(struct Packet *, Bignum b);
static int ssh2_pkt_construct(Ssh, struct Packet *); static int ssh2_pkt_construct(Ssh, struct Packet *);
static void ssh2_pkt_send(Ssh, struct Packet *); static void ssh2_pkt_send(Ssh, struct Packet *);
static void ssh2_pkt_send_noqueue(Ssh, struct Packet *); static void ssh2_pkt_send_noqueue(Ssh, struct Packet *);
static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen, static int do_ssh1_login(Ssh ssh, const unsigned char *in, int inlen,
struct Packet *pktin); struct Packet *pktin);
static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, static void do_ssh2_authconn(Ssh ssh, const unsigned char *in, int inlen,
struct Packet *pktin); struct Packet *pktin);
static void ssh2_channel_check_close(struct ssh_channel *c); static void ssh2_channel_check_close(struct ssh_channel *c);
static void ssh_channel_destroy(struct ssh_channel *c); static void ssh_channel_destroy(struct ssh_channel *c);
@ -686,11 +687,11 @@ struct Packet {
const char *additional_log_text; const char *additional_log_text;
}; };
static void ssh1_protocol(Ssh ssh, void *vin, int inlen, static void ssh1_protocol(Ssh ssh, const void *vin, int inlen,
struct Packet *pktin); struct Packet *pktin);
static void ssh2_protocol(Ssh ssh, void *vin, int inlen, static void ssh2_protocol(Ssh ssh, const void *vin, int inlen,
struct Packet *pktin); struct Packet *pktin);
static void ssh2_bare_connection_protocol(Ssh ssh, void *vin, int inlen, static void ssh2_bare_connection_protocol(Ssh ssh, const void *vin, int inlen,
struct Packet *pktin); struct Packet *pktin);
static void ssh1_protocol_setup(Ssh ssh); static void ssh1_protocol_setup(Ssh ssh);
static void ssh2_protocol_setup(Ssh ssh); static void ssh2_protocol_setup(Ssh ssh);
@ -698,7 +699,8 @@ static void ssh2_bare_connection_protocol_setup(Ssh ssh);
static void ssh_size(void *handle, int width, int height); static void ssh_size(void *handle, int width, int height);
static void ssh_special(void *handle, Telnet_Special); static void ssh_special(void *handle, Telnet_Special);
static int ssh2_try_send(struct ssh_channel *c); static int ssh2_try_send(struct ssh_channel *c);
static void ssh2_add_channel_data(struct ssh_channel *c, char *buf, int len); static void ssh2_add_channel_data(struct ssh_channel *c,
const char *buf, int len);
static void ssh_throttle_all(Ssh ssh, int enable, int bufsize); static void ssh_throttle_all(Ssh ssh, int enable, int bufsize);
static void ssh2_set_window(struct ssh_channel *c, int newwin); static void ssh2_set_window(struct ssh_channel *c, int newwin);
static int ssh_sendbuffer(void *handle); static int ssh_sendbuffer(void *handle);
@ -707,7 +709,7 @@ static unsigned long ssh_pkt_getuint32(struct Packet *pkt);
static int ssh2_pkt_getbool(struct Packet *pkt); static int ssh2_pkt_getbool(struct Packet *pkt);
static void ssh_pkt_getstring(struct Packet *pkt, char **p, int *length); static void ssh_pkt_getstring(struct Packet *pkt, char **p, int *length);
static void ssh2_timer(void *ctx, unsigned long now); static void ssh2_timer(void *ctx, unsigned long now);
static void do_ssh2_transport(Ssh ssh, void *vin, int inlen, static void do_ssh2_transport(Ssh ssh, const void *vin, int inlen,
struct Packet *pktin); struct Packet *pktin);
static void ssh2_msg_unexpected(Ssh ssh, struct Packet *pktin); static void ssh2_msg_unexpected(Ssh ssh, struct Packet *pktin);
@ -864,9 +866,10 @@ struct ssh_tag {
/* SSH-1 and SSH-2 use this for different things, but both use it */ /* SSH-1 and SSH-2 use this for different things, but both use it */
int protocol_initial_phase_done; int protocol_initial_phase_done;
void (*protocol) (Ssh ssh, void *vin, int inlen, void (*protocol) (Ssh ssh, const void *vin, int inlen,
struct Packet *pkt); struct Packet *pkt);
struct Packet *(*s_rdpkt) (Ssh ssh, unsigned char **data, int *datalen); struct Packet *(*s_rdpkt) (Ssh ssh, const unsigned char **data,
int *datalen);
int (*do_ssh_init)(Ssh ssh, unsigned char c); int (*do_ssh_init)(Ssh ssh, unsigned char c);
/* /*
@ -936,7 +939,7 @@ struct ssh_tag {
unsigned long max_data_size; unsigned long max_data_size;
int kex_in_progress; int kex_in_progress;
unsigned long next_rekey, last_rekey; unsigned long next_rekey, last_rekey;
char *deferred_rekey_reason; /* points to STATIC string; don't free */ const char *deferred_rekey_reason;
/* /*
* Fully qualified host name, which we need if doing GSSAPI. * Fully qualified host name, which we need if doing GSSAPI.
@ -1294,7 +1297,8 @@ static void ssh1_log_outgoing_packet(Ssh ssh, struct Packet *pkt)
* Update the *data and *datalen variables. * Update the *data and *datalen variables.
* Return a Packet structure when a packet is completed. * Return a Packet structure when a packet is completed.
*/ */
static struct Packet *ssh1_rdpkt(Ssh ssh, unsigned char **data, int *datalen) static struct Packet *ssh1_rdpkt(Ssh ssh, const unsigned char **data,
int *datalen)
{ {
struct rdpkt1_state_tag *st = &ssh->rdpkt1_state; struct rdpkt1_state_tag *st = &ssh->rdpkt1_state;
@ -1549,7 +1553,8 @@ static void ssh2_log_outgoing_packet(Ssh ssh, struct Packet *pkt)
pkt->length += (pkt->body - pkt->data); pkt->length += (pkt->body - pkt->data);
} }
static struct Packet *ssh2_rdpkt(Ssh ssh, unsigned char **data, int *datalen) static struct Packet *ssh2_rdpkt(Ssh ssh, const unsigned char **data,
int *datalen)
{ {
struct rdpkt2_state_tag *st = &ssh->rdpkt2_state; struct rdpkt2_state_tag *st = &ssh->rdpkt2_state;
@ -1837,7 +1842,8 @@ static struct Packet *ssh2_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
crFinish(st->pktin); crFinish(st->pktin);
} }
static struct Packet *ssh2_bare_connection_rdpkt(Ssh ssh, unsigned char **data, static struct Packet *ssh2_bare_connection_rdpkt(Ssh ssh,
const unsigned char **data,
int *datalen) int *datalen)
{ {
struct rdpkt2_bare_state_tag *st = &ssh->rdpkt2_bare_state; struct rdpkt2_bare_state_tag *st = &ssh->rdpkt2_bare_state;
@ -2050,7 +2056,7 @@ static void defer_packet(Ssh ssh, int pkttype, ...)
s_wrpkt_defer(ssh, pkt); s_wrpkt_defer(ssh, pkt);
} }
static int ssh_versioncmp(char *a, char *b) static int ssh_versioncmp(const char *a, const char *b)
{ {
char *ae, *be; char *ae, *be;
unsigned long av, bv; unsigned long av, bv;
@ -3243,7 +3249,7 @@ static int do_ssh_connection_init(Ssh ssh, unsigned char c)
} }
static void ssh_process_incoming_data(Ssh ssh, static void ssh_process_incoming_data(Ssh ssh,
unsigned char **data, int *datalen) const unsigned char **data, int *datalen)
{ {
struct Packet *pktin; struct Packet *pktin;
@ -3255,7 +3261,7 @@ static void ssh_process_incoming_data(Ssh ssh,
} }
static void ssh_queue_incoming_data(Ssh ssh, static void ssh_queue_incoming_data(Ssh ssh,
unsigned char **data, int *datalen) const unsigned char **data, int *datalen)
{ {
bufchain_add(&ssh->queued_incoming_data, *data, *datalen); bufchain_add(&ssh->queued_incoming_data, *data, *datalen);
*data += *datalen; *data += *datalen;
@ -3265,7 +3271,7 @@ static void ssh_queue_incoming_data(Ssh ssh,
static void ssh_process_queued_incoming_data(Ssh ssh) static void ssh_process_queued_incoming_data(Ssh ssh)
{ {
void *vdata; void *vdata;
unsigned char *data; const unsigned char *data;
int len, origlen; int len, origlen;
while (!ssh->frozen && bufchain_size(&ssh->queued_incoming_data)) { while (!ssh->frozen && bufchain_size(&ssh->queued_incoming_data)) {
@ -3288,7 +3294,7 @@ static void ssh_set_frozen(Ssh ssh, int frozen)
ssh->frozen = frozen; ssh->frozen = frozen;
} }
static void ssh_gotdata(Ssh ssh, unsigned char *data, int datalen) static void ssh_gotdata(Ssh ssh, const unsigned char *data, int datalen)
{ {
/* Log raw data, if we're in that mode. */ /* Log raw data, if we're in that mode. */
if (ssh->logctx) if (ssh->logctx)
@ -3533,7 +3539,7 @@ static void ssh_sent(Plug plug, int bufsize)
* Also places the canonical host name into `realhost'. It must be * Also places the canonical host name into `realhost'. It must be
* freed by the caller. * freed by the caller.
*/ */
static const char *connect_to_host(Ssh ssh, char *host, int port, static const char *connect_to_host(Ssh ssh, const char *host, int port,
char **realhost, int nodelay, int keepalive) char **realhost, int nodelay, int keepalive)
{ {
static const struct plug_function_table fn_table = { static const struct plug_function_table fn_table = {
@ -3740,7 +3746,7 @@ static void ssh_agentf_callback(void *cv, void *reply, int replylen)
{ {
struct ssh_channel *c = (struct ssh_channel *)cv; struct ssh_channel *c = (struct ssh_channel *)cv;
Ssh ssh = c->ssh; Ssh ssh = c->ssh;
void *sentreply = reply; const void *sentreply = reply;
c->u.a.outstanding_requests--; c->u.a.outstanding_requests--;
if (!sentreply) { if (!sentreply) {
@ -3773,7 +3779,8 @@ static void ssh_agentf_callback(void *cv, void *reply, int replylen)
* non-NULL, otherwise just close the connection. `client_reason' == NULL * non-NULL, otherwise just close the connection. `client_reason' == NULL
* => log `wire_reason'. * => log `wire_reason'.
*/ */
static void ssh_disconnect(Ssh ssh, char *client_reason, char *wire_reason, static void ssh_disconnect(Ssh ssh, const char *client_reason,
const char *wire_reason,
int code, int clean_exit) int code, int clean_exit)
{ {
char *error; char *error;
@ -3857,7 +3864,7 @@ int verify_ssh_manual_host_key(Ssh ssh, const char *fingerprint,
/* /*
* Handle the key exchange and user authentication phases. * Handle the key exchange and user authentication phases.
*/ */
static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen, static int do_ssh1_login(Ssh ssh, const unsigned char *in, int inlen,
struct Packet *pktin) struct Packet *pktin)
{ {
int i, j, ret; int i, j, ret;
@ -4038,7 +4045,7 @@ static int do_ssh1_login(Ssh ssh, unsigned char *in, int inlen,
{ {
int cipher_chosen = 0, warn = 0; int cipher_chosen = 0, warn = 0;
char *cipher_string = NULL; const char *cipher_string = NULL;
int i; int i;
for (i = 0; !cipher_chosen && i < CIPHER_MAX; i++) { for (i = 0; !cipher_chosen && i < CIPHER_MAX; i++) {
int next_cipher = conf_get_int_int(ssh->conf, int next_cipher = conf_get_int_int(ssh->conf,
@ -5773,7 +5780,7 @@ int ssh_agent_forwarding_permitted(Ssh ssh)
return conf_get_int(ssh->conf, CONF_agentfwd) && agent_exists(); return conf_get_int(ssh->conf, CONF_agentfwd) && agent_exists();
} }
static void do_ssh1_connection(Ssh ssh, unsigned char *in, int inlen, static void do_ssh1_connection(Ssh ssh, const unsigned char *in, int inlen,
struct Packet *pktin) struct Packet *pktin)
{ {
crBegin(ssh->do_ssh1_connection_crstate); crBegin(ssh->do_ssh1_connection_crstate);
@ -6028,10 +6035,10 @@ static void ssh1_protocol_setup(Ssh ssh)
ssh->packet_dispatch[SSH1_MSG_DEBUG] = ssh1_msg_debug; ssh->packet_dispatch[SSH1_MSG_DEBUG] = ssh1_msg_debug;
} }
static void ssh1_protocol(Ssh ssh, void *vin, int inlen, static void ssh1_protocol(Ssh ssh, const void *vin, int inlen,
struct Packet *pktin) struct Packet *pktin)
{ {
unsigned char *in=(unsigned char*)vin; const unsigned char *in = (const unsigned char *)vin;
if (ssh->state == SSH_STATE_CLOSED) if (ssh->state == SSH_STATE_CLOSED)
return; return;
@ -6149,10 +6156,10 @@ static void ssh2_mkkey(Ssh ssh, Bignum K, unsigned char *H, char chr,
/* /*
* Handle the SSH-2 transport layer. * Handle the SSH-2 transport layer.
*/ */
static void do_ssh2_transport(Ssh ssh, void *vin, int inlen, static void do_ssh2_transport(Ssh ssh, const void *vin, int inlen,
struct Packet *pktin) struct Packet *pktin)
{ {
unsigned char *in = (unsigned char *)vin; const unsigned char *in = (const unsigned char *)vin;
struct do_ssh2_transport_state { struct do_ssh2_transport_state {
int crLine; int crLine;
int nbits, pbits, warn_kex, warn_cscipher, warn_sccipher; int nbits, pbits, warn_kex, warn_cscipher, warn_sccipher;
@ -6405,7 +6412,8 @@ static void do_ssh2_transport(Ssh ssh, void *vin, int inlen,
* to. * to.
*/ */
{ {
char *str, *preferred; char *str;
const char *preferred;
int i, j, len; int i, j, len;
if (pktin->type != SSH2_MSG_KEXINIT) { if (pktin->type != SSH2_MSG_KEXINIT) {
@ -7354,7 +7362,7 @@ static void do_ssh2_transport(Ssh ssh, void *vin, int inlen,
/* /*
* Add data to an SSH-2 channel output buffer. * Add data to an SSH-2 channel output buffer.
*/ */
static void ssh2_add_channel_data(struct ssh_channel *c, char *buf, static void ssh2_add_channel_data(struct ssh_channel *c, const char *buf,
int len) int len)
{ {
bufchain_add(&c->v.v2.outbuffer, buf, len); bufchain_add(&c->v.v2.outbuffer, buf, len);
@ -7461,7 +7469,8 @@ static void ssh2_channel_init(struct ssh_channel *c)
/* /*
* Construct the common parts of a CHANNEL_OPEN. * Construct the common parts of a CHANNEL_OPEN.
*/ */
static struct Packet *ssh2_chanopen_init(struct ssh_channel *c, char *type) static struct Packet *ssh2_chanopen_init(struct ssh_channel *c,
const char *type)
{ {
struct Packet *pktout; struct Packet *pktout;
@ -7508,7 +7517,8 @@ static void ssh2_queue_chanreq_handler(struct ssh_channel *c,
* the server initiated channel closure before we saw the response) * the server initiated channel closure before we saw the response)
* and the handler should free any storage it's holding. * and the handler should free any storage it's holding.
*/ */
static struct Packet *ssh2_chanreq_init(struct ssh_channel *c, char *type, static struct Packet *ssh2_chanreq_init(struct ssh_channel *c,
const char *type,
cchandler_fn_t handler, void *ctx) cchandler_fn_t handler, void *ctx)
{ {
struct Packet *pktout; struct Packet *pktout;
@ -8218,7 +8228,7 @@ static void ssh2_msg_channel_request(Ssh ssh, struct Packet *pktin)
!memcmp(type, "exit-signal", 11)) { !memcmp(type, "exit-signal", 11)) {
int is_plausible = TRUE, is_int = FALSE; int is_plausible = TRUE, is_int = FALSE;
char *fmt_sig = "", *fmt_msg = ""; char *fmt_sig = NULL, *fmt_msg = NULL;
char *msg; char *msg;
int msglen = 0, core = FALSE; int msglen = 0, core = FALSE;
/* ICK: older versions of OpenSSH (e.g. 3.4p1) /* ICK: older versions of OpenSSH (e.g. 3.4p1)
@ -8341,10 +8351,11 @@ static void ssh2_msg_channel_request(Ssh ssh, struct Packet *pktin)
/* ignore lang tag */ /* ignore lang tag */
} /* else don't attempt to parse */ } /* else don't attempt to parse */
logeventf(ssh, "Server exited on signal%s%s%s", logeventf(ssh, "Server exited on signal%s%s%s",
fmt_sig, core ? " (core dumped)" : "", fmt_sig ? fmt_sig : "",
fmt_msg); core ? " (core dumped)" : "",
if (*fmt_sig) sfree(fmt_sig); fmt_msg ? fmt_msg : "");
if (*fmt_msg) sfree(fmt_msg); sfree(fmt_sig);
sfree(fmt_msg);
reply = SSH2_MSG_CHANNEL_SUCCESS; reply = SSH2_MSG_CHANNEL_SUCCESS;
} }
@ -8416,7 +8427,7 @@ static void ssh2_msg_channel_open(Ssh ssh, struct Packet *pktin)
char *peeraddr; char *peeraddr;
int peeraddrlen; int peeraddrlen;
int peerport; int peerport;
char *error = NULL; const char *error = NULL;
struct ssh_channel *c; struct ssh_channel *c;
unsigned remid, winsize, pktsize; unsigned remid, winsize, pktsize;
unsigned our_winsize_override = 0; unsigned our_winsize_override = 0;
@ -8829,7 +8840,7 @@ static void ssh2_response_authconn(struct ssh_channel *c, struct Packet *pktin,
do_ssh2_authconn(c->ssh, NULL, 0, pktin); do_ssh2_authconn(c->ssh, NULL, 0, pktin);
} }
static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen, static void do_ssh2_authconn(Ssh ssh, const unsigned char *in, int inlen,
struct Packet *pktin) struct Packet *pktin)
{ {
struct do_ssh2_authconn_state { struct do_ssh2_authconn_state {
@ -10116,7 +10127,7 @@ static void do_ssh2_authconn(Ssh ssh, unsigned char *in, int inlen,
int prompt_len; /* not live over crReturn */ int prompt_len; /* not live over crReturn */
{ {
char *msg; const char *msg;
if (changereq_first_time) if (changereq_first_time)
msg = "Server requested password change"; msg = "Server requested password change";
else else
@ -10740,10 +10751,10 @@ static void ssh2_timer(void *ctx, unsigned long now)
} }
} }
static void ssh2_protocol(Ssh ssh, void *vin, int inlen, static void ssh2_protocol(Ssh ssh, const void *vin, int inlen,
struct Packet *pktin) struct Packet *pktin)
{ {
unsigned char *in = (unsigned char *)vin; const unsigned char *in = (const unsigned char *)vin;
if (ssh->state == SSH_STATE_CLOSED) if (ssh->state == SSH_STATE_CLOSED)
return; return;
@ -10763,10 +10774,10 @@ static void ssh2_protocol(Ssh ssh, void *vin, int inlen,
do_ssh2_authconn(ssh, in, inlen, pktin); do_ssh2_authconn(ssh, in, inlen, pktin);
} }
static void ssh2_bare_connection_protocol(Ssh ssh, void *vin, int inlen, static void ssh2_bare_connection_protocol(Ssh ssh, const void *vin, int inlen,
struct Packet *pktin) struct Packet *pktin)
{ {
unsigned char *in = (unsigned char *)vin; const unsigned char *in = (const unsigned char *)vin;
if (ssh->state == SSH_STATE_CLOSED) if (ssh->state == SSH_STATE_CLOSED)
return; return;
@ -10787,7 +10798,8 @@ static void ssh_cache_conf_values(Ssh ssh)
* Returns an error message, or NULL on success. * Returns an error message, or NULL on success.
*/ */
static const char *ssh_init(void *frontend_handle, void **backend_handle, static const char *ssh_init(void *frontend_handle, void **backend_handle,
Conf *conf, char *host, int port, char **realhost, Conf *conf,
const char *host, int port, char **realhost,
int nodelay, int keepalive) int nodelay, int keepalive)
{ {
const char *p; const char *p;
@ -11039,7 +11051,8 @@ static void ssh_free(void *handle)
static void ssh_reconfig(void *handle, Conf *conf) static void ssh_reconfig(void *handle, Conf *conf)
{ {
Ssh ssh = (Ssh) handle; Ssh ssh = (Ssh) handle;
char *rekeying = NULL, rekey_mandatory = FALSE; const char *rekeying = NULL;
int rekey_mandatory = FALSE;
unsigned long old_max_data_size; unsigned long old_max_data_size;
int i, rekey_time; int i, rekey_time;
@ -11104,14 +11117,14 @@ static void ssh_reconfig(void *handle, Conf *conf)
/* /*
* Called to send data down the SSH connection. * Called to send data down the SSH connection.
*/ */
static int ssh_send(void *handle, char *buf, int len) static int ssh_send(void *handle, const char *buf, int len)
{ {
Ssh ssh = (Ssh) handle; Ssh ssh = (Ssh) handle;
if (ssh == NULL || ssh->s == NULL || ssh->protocol == NULL) if (ssh == NULL || ssh->s == NULL || ssh->protocol == NULL)
return 0; return 0;
ssh->protocol(ssh, (unsigned char *)buf, len, 0); ssh->protocol(ssh, (const unsigned char *)buf, len, 0);
return ssh_sendbuffer(ssh); return ssh_sendbuffer(ssh);
} }
@ -11319,7 +11332,7 @@ static void ssh_special(void *handle, Telnet_Special code)
} }
} else { } else {
/* Is is a POSIX signal? */ /* Is is a POSIX signal? */
char *signame = NULL; const char *signame = NULL;
if (code == TS_SIGABRT) signame = "ABRT"; if (code == TS_SIGABRT) signame = "ABRT";
if (code == TS_SIGALRM) signame = "ALRM"; if (code == TS_SIGALRM) signame = "ALRM";
if (code == TS_SIGFPE) signame = "FPE"; if (code == TS_SIGFPE) signame = "FPE";
@ -11436,7 +11449,8 @@ static void ssh_unthrottle(void *handle, int bufsize)
ssh_process_queued_incoming_data(ssh); ssh_process_queued_incoming_data(ssh);
} }
void ssh_send_port_open(void *channel, char *hostname, int port, char *org) void ssh_send_port_open(void *channel, const char *hostname, int port,
const char *org)
{ {
struct ssh_channel *c = (struct ssh_channel *)channel; struct ssh_channel *c = (struct ssh_channel *)channel;
Ssh ssh = c->ssh; Ssh ssh = c->ssh;

13
ssh.h
View File

@ -304,7 +304,7 @@ struct ssh2_cipher {
void (*setkey) (void *, unsigned char *key);/* for SSH-2 */ void (*setkey) (void *, unsigned char *key);/* for SSH-2 */
void (*encrypt) (void *, unsigned char *blk, int len); void (*encrypt) (void *, unsigned char *blk, int len);
void (*decrypt) (void *, unsigned char *blk, int len); void (*decrypt) (void *, unsigned char *blk, int len);
char *name; const char *name;
int blksize; int blksize;
int keylen; int keylen;
unsigned int flags; unsigned int flags;
@ -343,7 +343,7 @@ struct ssh_hash {
}; };
struct ssh_kex { struct ssh_kex {
char *name, *groupname; const char *name, *groupname;
enum { KEXTYPE_DH, KEXTYPE_RSA, KEXTYPE_ECDH } main_type; enum { KEXTYPE_DH, KEXTYPE_RSA, KEXTYPE_ECDH } main_type;
const struct ssh_hash *hash; const struct ssh_hash *hash;
const void *extra; /* private to the kex methods */ const void *extra; /* private to the kex methods */
@ -388,10 +388,10 @@ struct ssh_signkey {
}; };
struct ssh_compress { struct ssh_compress {
char *name; const char *name;
/* For zlib@openssh.com: if non-NULL, this name will be considered once /* For zlib@openssh.com: if non-NULL, this name will be considered once
* userauth has completed successfully. */ * userauth has completed successfully. */
char *delayed_name; const char *delayed_name;
void *(*compress_init) (void); void *(*compress_init) (void);
void (*compress_cleanup) (void *); void (*compress_cleanup) (void *);
int (*compress) (void *, unsigned char *block, int len, int (*compress) (void *, unsigned char *block, int len,
@ -478,7 +478,8 @@ struct PortForwarding;
/* Allocate and register a new channel for port forwarding */ /* Allocate and register a new channel for port forwarding */
void *new_sock_channel(void *handle, struct PortForwarding *pf); void *new_sock_channel(void *handle, struct PortForwarding *pf);
void ssh_send_port_open(void *channel, char *hostname, int port, char *org); void ssh_send_port_open(void *channel, const char *hostname, int port,
const char *org);
/* Exports from portfwd.c */ /* Exports from portfwd.c */
extern char *pfd_connect(struct PortForwarding **pf, char *hostname, int port, extern char *pfd_connect(struct PortForwarding **pf, char *hostname, int port,
@ -729,7 +730,7 @@ void ssh2_write_pubkey(FILE *fp, const char *comment,
char *ssh2_fingerprint_blob(const void *blob, int bloblen); char *ssh2_fingerprint_blob(const void *blob, int bloblen);
char *ssh2_fingerprint(const struct ssh_signkey *alg, void *data); char *ssh2_fingerprint(const struct ssh_signkey *alg, void *data);
int key_type(const Filename *filename); int key_type(const Filename *filename);
char *key_type_to_str(int type); const char *key_type_to_str(int type);
int import_possible(int type); int import_possible(int type);
int import_target_type(int type); int import_target_type(int type);

View File

@ -1970,7 +1970,7 @@ char *bignum_decimal(Bignum x)
* testdata/bignum.py . * testdata/bignum.py .
*/ */
void modalfatalbox(char *p, ...) void modalfatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");

View File

@ -1308,7 +1308,7 @@ int ssh2_save_userkey(const Filename *filename, struct ssh2_userkey *key,
int passlen; int passlen;
int cipherblk; int cipherblk;
int i; int i;
char *cipherstr; const char *cipherstr;
unsigned char priv_mac[20]; unsigned char priv_mac[20];
/* /*
@ -1688,7 +1688,7 @@ int key_type(const Filename *filename)
* Convert the type word to a string, for `wrong type' error * Convert the type word to a string, for `wrong type' error
* messages. * messages.
*/ */
char *key_type_to_str(int type) const char *key_type_to_str(int type)
{ {
switch (type) { switch (type) {
case SSH_KEYTYPE_UNOPENABLE: return "unable to open file"; break; case SSH_KEYTYPE_UNOPENABLE: return "unable to open file"; break;

View File

@ -113,7 +113,7 @@ enum { TELOPTS(telnet_enum) dummy=0 };
( (x) != IAC && \ ( (x) != IAC && \
(telnet->opt_states[o_we_bin.index] == ACTIVE || (x) != CR)) (telnet->opt_states[o_we_bin.index] == ACTIVE || (x) != CR))
static char *telopt(int opt) static const char *telopt(int opt)
{ {
#define telnet_str(x,y) case TELOPT_##x: return #x; #define telnet_str(x,y) case TELOPT_##x: return #x;
switch (opt) { switch (opt) {
@ -212,14 +212,14 @@ typedef struct telnet_tag {
#define SB_DELTA 1024 #define SB_DELTA 1024
static void c_write(Telnet telnet, char *buf, int len) static void c_write(Telnet telnet, const char *buf, int len)
{ {
int backlog; int backlog;
backlog = from_backend(telnet->frontend, 0, buf, len); backlog = from_backend(telnet->frontend, 0, buf, len);
sk_set_frozen(telnet->s, backlog > TELNET_MAX_BACKLOG); sk_set_frozen(telnet->s, backlog > TELNET_MAX_BACKLOG);
} }
static void log_option(Telnet telnet, char *sender, int cmd, int option) static void log_option(Telnet telnet, const char *sender, int cmd, int option)
{ {
char *buf; char *buf;
/* /*
@ -715,7 +715,7 @@ static void telnet_sent(Plug plug, int bufsize)
* freed by the caller. * freed by the caller.
*/ */
static const char *telnet_init(void *frontend_handle, void **backend_handle, static const char *telnet_init(void *frontend_handle, void **backend_handle,
Conf *conf, char *host, int port, Conf *conf, const char *host, int port,
char **realhost, int nodelay, int keepalive) char **realhost, int nodelay, int keepalive)
{ {
static const struct plug_function_table fn_table = { static const struct plug_function_table fn_table = {
@ -855,7 +855,7 @@ static void telnet_reconfig(void *handle, Conf *conf)
/* /*
* Called to send data down the Telnet connection. * Called to send data down the Telnet connection.
*/ */
static int telnet_send(void *handle, char *buf, int len) static int telnet_send(void *handle, const char *buf, int len)
{ {
Telnet telnet = (Telnet) handle; Telnet telnet = (Telnet) handle;
unsigned char *p, *end; unsigned char *p, *end;

View File

@ -65,7 +65,7 @@
#define has_compat(x) ( ((CL_##x)&term->compatibility_level) != 0 ) #define has_compat(x) ( ((CL_##x)&term->compatibility_level) != 0 )
char *EMPTY_WINDOW_TITLE = ""; const char *EMPTY_WINDOW_TITLE = "";
const char sco2ansicolour[] = { 0, 4, 2, 6, 1, 5, 3, 7 }; const char sco2ansicolour[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
@ -3940,7 +3940,8 @@ static void term_out(Terminal *term)
switch (term->esc_args[0]) { switch (term->esc_args[0]) {
int x, y, len; int x, y, len;
char buf[80], *p; char buf[80];
const char *p;
case 1: case 1:
set_iconic(term->frontend, FALSE); set_iconic(term->frontend, FALSE);
break; break;
@ -6319,7 +6320,7 @@ void term_set_focus(Terminal *term, int has_focus)
*/ */
char *term_get_ttymode(Terminal *term, const char *mode) char *term_get_ttymode(Terminal *term, const char *mode)
{ {
char *val = NULL; const char *val = NULL;
if (strcmp(mode, "ERASE") == 0) { if (strcmp(mode, "ERASE") == 0) {
val = term->bksp_is_delete ? "^?" : "^H"; val = term->bksp_is_delete ? "^?" : "^H";
} }
@ -6339,7 +6340,7 @@ struct term_userpass_state {
* input. * input.
*/ */
int term_get_userpass_input(Terminal *term, prompts_t *p, int term_get_userpass_input(Terminal *term, prompts_t *p,
unsigned char *in, int inlen) const unsigned char *in, int inlen)
{ {
struct term_userpass_state *s = (struct term_userpass_state *)p->data; struct term_userpass_state *s = (struct term_userpass_state *)p->data;
if (!s) { if (!s) {

View File

@ -342,7 +342,7 @@ char *gtk_askpass_main(const char *display, const char *wintitle,
} }
#ifdef TEST_ASKPASS #ifdef TEST_ASKPASS
void modalfatalbox(char *p, ...) void modalfatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");

View File

@ -1055,7 +1055,7 @@ static void set_transient_window_pos(GtkWidget *parent, GtkWidget *child)
gtk_widget_set_uposition(GTK_WIDGET(child), dx, dy); gtk_widget_set_uposition(GTK_WIDGET(child), dx, dy);
} }
void dlg_error_msg(void *dlg, char *msg) void dlg_error_msg(void *dlg, const char *msg)
{ {
struct dlgparam *dp = (struct dlgparam *)dlg; struct dlgparam *dp = (struct dlgparam *)dlg;
GtkWidget *window, *hbox, *text, *ok; GtkWidget *window, *hbox, *text, *ok;
@ -1998,7 +1998,7 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
{ {
GtkWidget *ww; GtkWidget *ww;
GtkRequisition req; GtkRequisition req;
char *browsebtn = const char *browsebtn =
(ctrl->generic.type == CTRL_FILESELECT ? (ctrl->generic.type == CTRL_FILESELECT ?
"Browse..." : "Change..."); "Browse..." : "Change...");
@ -3138,7 +3138,8 @@ static void messagebox_handler(union control *ctrl, void *dlg,
if (event == EVENT_ACTION) if (event == EVENT_ACTION)
dlg_end(dlg, ctrl->generic.context.i); dlg_end(dlg, ctrl->generic.context.i);
} }
int messagebox(GtkWidget *parentwin, char *title, char *msg, int minwid, ...) int messagebox(GtkWidget *parentwin, const char *title, const char *msg,
int minwid, ...)
{ {
GtkWidget *window, *w0, *w1; GtkWidget *window, *w0, *w1;
struct controlbox *ctrlbox; struct controlbox *ctrlbox;
@ -3235,7 +3236,7 @@ int messagebox(GtkWidget *parentwin, char *title, char *msg, int minwid, ...)
return dp.retval; return dp.retval;
} }
int string_width(char *text) int string_width(const char *text)
{ {
GtkWidget *label = gtk_label_new(text); GtkWidget *label = gtk_label_new(text);
GtkRequisition req; GtkRequisition req;
@ -3355,21 +3356,21 @@ void old_keyfile_warning(void)
*/ */
} }
void fatal_message_box(void *window, char *msg) void fatal_message_box(void *window, const char *msg)
{ {
messagebox(window, "PuTTY Fatal Error", msg, messagebox(window, "PuTTY Fatal Error", msg,
string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"), string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"),
"OK", 'o', 1, 1, NULL); "OK", 'o', 1, 1, NULL);
} }
void nonfatal_message_box(void *window, char *msg) void nonfatal_message_box(void *window, const char *msg)
{ {
messagebox(window, "PuTTY Error", msg, messagebox(window, "PuTTY Error", msg,
string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"), string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"),
"OK", 'o', 1, 1, NULL); "OK", 'o', 1, 1, NULL);
} }
void fatalbox(char *p, ...) void fatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
char *msg; char *msg;
@ -3381,7 +3382,7 @@ void fatalbox(char *p, ...)
cleanup_exit(1); cleanup_exit(1);
} }
void nonfatal(char *p, ...) void nonfatal(const char *p, ...)
{ {
va_list ap; va_list ap;
char *msg; char *msg;
@ -3404,7 +3405,7 @@ static void licence_clicked(GtkButton *button, gpointer data)
{ {
char *title; char *title;
char *licence = const char *licence =
"Copyright 1997-2015 Simon Tatham.\n\n" "Copyright 1997-2015 Simon Tatham.\n\n"
"Portions copyright Robert de Bath, Joris van Rantwijk, Delian " "Portions copyright Robert de Bath, Joris van Rantwijk, Delian "

View File

@ -175,7 +175,7 @@ static char *x11_guess_derived_font_name(XFontStruct *xfs, int bold, int wide)
if (XGetFontProperty(xfs, fontprop, &ret)) { if (XGetFontProperty(xfs, fontprop, &ret)) {
char *name = XGetAtomName(disp, (Atom)ret); char *name = XGetAtomName(disp, (Atom)ret);
if (name && name[0] == '-') { if (name && name[0] == '-') {
char *strings[13]; const char *strings[13];
char *dupname, *extrafree = NULL, *ret; char *dupname, *extrafree = NULL, *ret;
char *p, *q; char *p, *q;
int nstr; int nstr;

View File

@ -133,7 +133,7 @@ struct draw_ctx {
static int send_raw_mouse; static int send_raw_mouse;
static char *app_name = "pterm"; static const char *app_name = "pterm";
static void start_backend(struct gui_data *inst); static void start_backend(struct gui_data *inst);
static void exit_callback(void *vinst); static void exit_callback(void *vinst);
@ -143,7 +143,7 @@ char *x_get_default(const char *key)
return XGetDefault(GDK_DISPLAY(), app_name, key); return XGetDefault(GDK_DISPLAY(), app_name, key);
} }
void connection_fatal(void *frontend, char *p, ...) void connection_fatal(void *frontend, const char *p, ...)
{ {
struct gui_data *inst = (struct gui_data *)frontend; struct gui_data *inst = (struct gui_data *)frontend;
@ -221,7 +221,7 @@ int from_backend_eof(void *frontend)
return TRUE; /* do respond to incoming EOF with outgoing */ return TRUE; /* do respond to incoming EOF with outgoing */
} }
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen) int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{ {
struct gui_data *inst = (struct gui_data *)p->frontend; struct gui_data *inst = (struct gui_data *)p->frontend;
int ret; int ret;
@ -885,7 +885,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
* NetHack keypad mode. * NetHack keypad mode.
*/ */
if (nethack_mode) { if (nethack_mode) {
char *keys = NULL; const char *keys = NULL;
switch (event->keyval) { switch (event->keyval) {
case GDK_KP_1: case GDK_KP_End: keys = "bB\002"; break; case GDK_KP_1: case GDK_KP_End: keys = "bB\002"; break;
case GDK_KP_2: case GDK_KP_Down: keys = "jJ\012"; break; case GDK_KP_2: case GDK_KP_Down: keys = "jJ\012"; break;
@ -2603,7 +2603,7 @@ GdkCursor *make_mouse_ptr(struct gui_data *inst, int cursor_val)
return ret; return ret;
} }
void modalfatalbox(char *p, ...) void modalfatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");
@ -2614,7 +2614,7 @@ void modalfatalbox(char *p, ...)
exit(1); exit(1);
} }
void cmdline_error(char *p, ...) void cmdline_error(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "%s: ", appname); fprintf(stderr, "%s: ", appname);
@ -2695,7 +2695,7 @@ int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
#define SECOND_PASS_ONLY { if (!do_everything) continue; } #define SECOND_PASS_ONLY { if (!do_everything) continue; }
while (--argc > 0) { while (--argc > 0) {
char *p = *++argv; const char *p = *++argv;
int ret; int ret;
/* /*

View File

@ -84,21 +84,22 @@ void *get_window(void *frontend); /* void * to avoid depending on gtk.h */
/* Things pterm.c needs from gtkdlg.c */ /* Things pterm.c needs from gtkdlg.c */
int do_config_box(const char *title, Conf *conf, int do_config_box(const char *title, Conf *conf,
int midsession, int protcfginfo); int midsession, int protcfginfo);
void fatal_message_box(void *window, char *msg); void fatal_message_box(void *window, const char *msg);
void nonfatal_message_box(void *window, char *msg); void nonfatal_message_box(void *window, const char *msg);
void about_box(void *window); void about_box(void *window);
void *eventlogstuff_new(void); void *eventlogstuff_new(void);
void showeventlog(void *estuff, void *parentwin); void showeventlog(void *estuff, void *parentwin);
void logevent_dlg(void *estuff, const char *string); void logevent_dlg(void *estuff, const char *string);
int reallyclose(void *frontend); int reallyclose(void *frontend);
#ifdef MAY_REFER_TO_GTK_IN_HEADERS #ifdef MAY_REFER_TO_GTK_IN_HEADERS
int messagebox(GtkWidget *parentwin, char *title, char *msg, int minwid, ...); int messagebox(GtkWidget *parentwin, const char *title,
int string_width(char *text); const char *msg, int minwid, ...);
int string_width(const char *text);
#endif #endif
/* Things pterm.c needs from {ptermm,uxputty}.c */ /* Things pterm.c needs from {ptermm,uxputty}.c */
char *make_default_wintitle(char *hostname); char *make_default_wintitle(char *hostname);
int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch); int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch);
/* pterm.c needs this special function in xkeysym.c */ /* pterm.c needs this special function in xkeysym.c */
int keysym_to_unicode(int keysym); int keysym_to_unicode(int keysym);

View File

@ -364,7 +364,8 @@ static void console_prompt_text(FILE *outfp, const char *data, int len)
fflush(outfp); fflush(outfp);
} }
int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen) int console_get_userpass_input(prompts_t *p, const unsigned char *in,
int inlen)
{ {
size_t curr_prompt; size_t curr_prompt;
FILE *outfp = NULL; FILE *outfp = NULL;

View File

@ -98,7 +98,7 @@ Filename *filename_deserialise(void *vdata, int maxsize, int *used)
#ifdef DEBUG #ifdef DEBUG
static FILE *debug_fp = NULL; static FILE *debug_fp = NULL;
void dputs(char *buf) void dputs(const char *buf)
{ {
if (!debug_fp) { if (!debug_fp) {
debug_fp = fopen("debug.log", "w"); debug_fp = fopen("debug.log", "w");

View File

@ -776,7 +776,8 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
return (Socket) ret; return (Socket) ret;
} }
Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, int orig_address_family) Socket sk_newlistener(const char *srcaddr, int port, Plug plug,
int local_host_only, int orig_address_family)
{ {
int s; int s;
#ifndef NO_IPV6 #ifndef NO_IPV6

View File

@ -23,7 +23,7 @@
SockAddr unix_sock_addr(const char *path); SockAddr unix_sock_addr(const char *path);
Socket new_unix_listener(SockAddr listenaddr, Plug plug); Socket new_unix_listener(SockAddr listenaddr, Plug plug);
void fatalbox(char *p, ...) void fatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");
@ -33,7 +33,7 @@ void fatalbox(char *p, ...)
fputc('\n', stderr); fputc('\n', stderr);
exit(1); exit(1);
} }
void modalfatalbox(char *p, ...) void modalfatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");
@ -43,7 +43,7 @@ void modalfatalbox(char *p, ...)
fputc('\n', stderr); fputc('\n', stderr);
exit(1); exit(1);
} }
void nonfatal(char *p, ...) void nonfatal(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "ERROR: "); fprintf(stderr, "ERROR: ");
@ -52,7 +52,7 @@ void nonfatal(char *p, ...)
va_end(ap); va_end(ap);
fputc('\n', stderr); fputc('\n', stderr);
} }
void connection_fatal(void *frontend, char *p, ...) void connection_fatal(void *frontend, const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");
@ -62,7 +62,7 @@ void connection_fatal(void *frontend, char *p, ...)
fputc('\n', stderr); fputc('\n', stderr);
exit(1); exit(1);
} }
void cmdline_error(char *p, ...) void cmdline_error(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "pageant: "); fprintf(stderr, "pageant: ");

View File

@ -29,7 +29,7 @@ void *logctx;
static struct termios orig_termios; static struct termios orig_termios;
void fatalbox(char *p, ...) void fatalbox(const char *p, ...)
{ {
struct termios cf; struct termios cf;
va_list ap; va_list ap;
@ -46,7 +46,7 @@ void fatalbox(char *p, ...)
} }
cleanup_exit(1); cleanup_exit(1);
} }
void modalfatalbox(char *p, ...) void modalfatalbox(const char *p, ...)
{ {
struct termios cf; struct termios cf;
va_list ap; va_list ap;
@ -63,7 +63,7 @@ void modalfatalbox(char *p, ...)
} }
cleanup_exit(1); cleanup_exit(1);
} }
void nonfatal(char *p, ...) void nonfatal(const char *p, ...)
{ {
struct termios cf; struct termios cf;
va_list ap; va_list ap;
@ -75,7 +75,7 @@ void nonfatal(char *p, ...)
fputc('\n', stderr); fputc('\n', stderr);
postmsg(&cf); postmsg(&cf);
} }
void connection_fatal(void *frontend, char *p, ...) void connection_fatal(void *frontend, const char *p, ...)
{ {
struct termios cf; struct termios cf;
va_list ap; va_list ap;
@ -92,7 +92,7 @@ void connection_fatal(void *frontend, char *p, ...)
} }
cleanup_exit(1); cleanup_exit(1);
} }
void cmdline_error(char *p, ...) void cmdline_error(const char *p, ...)
{ {
struct termios cf; struct termios cf;
va_list ap; va_list ap;
@ -446,7 +446,7 @@ int from_backend_eof(void *frontend_handle)
return FALSE; /* do not respond to incoming EOF with outgoing */ return FALSE; /* do not respond to incoming EOF with outgoing */
} }
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen) int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{ {
int ret; int ret;
ret = cmdline_get_passwd_input(p, in, inlen); ret = cmdline_get_passwd_input(p, in, inlen);

View File

@ -230,7 +230,7 @@ static int localproxy_select_result(int fd, int event)
return 1; return 1;
} }
Socket platform_new_connection(SockAddr addr, char *hostname, Socket platform_new_connection(SockAddr addr, const char *hostname,
int port, int privport, int port, int privport,
int oobinline, int nodelay, int keepalive, int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf) Plug plug, Conf *conf)

View File

@ -33,7 +33,7 @@ void cleanup_exit(int code)
exit(code); exit(code);
} }
int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch) int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch)
{ {
return 0; /* pterm doesn't have any. */ return 0; /* pterm doesn't have any. */
} }

View File

@ -706,8 +706,8 @@ static void pty_uxsel_setup(Pty pty)
* freed by the caller. * freed by the caller.
*/ */
static const char *pty_init(void *frontend, void **backend_handle, Conf *conf, static const char *pty_init(void *frontend, void **backend_handle, Conf *conf,
char *host, int port, char **realhost, int nodelay, const char *host, int port, char **realhost,
int keepalive) int nodelay, int keepalive)
{ {
int slavefd; int slavefd;
pid_t pid, pgrp; pid_t pid, pgrp;
@ -1008,7 +1008,7 @@ static void pty_try_write(Pty pty)
/* /*
* Called to send data down the pty. * Called to send data down the pty.
*/ */
static int pty_send(void *handle, char *buf, int len) static int pty_send(void *handle, const char *buf, int len)
{ {
Pty pty = (Pty)handle; Pty pty = (Pty)handle;

View File

@ -50,9 +50,11 @@ static int got_host = 0;
const int use_event_log = 1, new_session = 1, saved_sessions = 1; const int use_event_log = 1, new_session = 1, saved_sessions = 1;
int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch) int process_nonoption_arg(const char *arg, Conf *conf, int *allow_launch)
{ {
char *p, *q = arg; char *argdup, *p, *q;
argdup = dupstr(arg);
q = argdup;
if (got_host) { if (got_host) {
/* /*
@ -61,7 +63,7 @@ int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch)
* argument, so that it will be deferred until it's a good * argument, so that it will be deferred until it's a good
* moment to run it. * moment to run it.
*/ */
int ret = cmdline_process_param("-P", arg, 1, conf); int ret = cmdline_process_param("-P", argdup, 1, conf);
assert(ret == 2); assert(ret == 2);
} else if (!strncmp(q, "telnet:", 7)) { } else if (!strncmp(q, "telnet:", 7)) {
/* /*
@ -90,7 +92,7 @@ int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch)
/* /*
* Otherwise, treat this argument as a host name. * Otherwise, treat this argument as a host name.
*/ */
p = arg; p = argdup;
while (*p && !isspace((unsigned char)*p)) while (*p && !isspace((unsigned char)*p))
p++; p++;
if (*p) if (*p)
@ -100,6 +102,9 @@ int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch)
} }
if (got_host) if (got_host)
*allow_launch = TRUE; *allow_launch = TRUE;
sfree(argdup);
return 1; return 1;
} }

View File

@ -289,8 +289,8 @@ static const char *serial_configure(Serial serial, Conf *conf)
*/ */
static const char *serial_init(void *frontend_handle, void **backend_handle, static const char *serial_init(void *frontend_handle, void **backend_handle,
Conf *conf, Conf *conf,
char *host, int port, char **realhost, int nodelay, const char *host, int port, char **realhost,
int keepalive) int nodelay, int keepalive)
{ {
Serial serial; Serial serial;
const char *err; const char *err;
@ -462,7 +462,7 @@ static void serial_try_write(Serial serial)
/* /*
* Called to send data down the serial connection. * Called to send data down the serial connection.
*/ */
static int serial_send(void *handle, char *buf, int len) static int serial_send(void *handle, const char *buf, int len)
{ {
Serial serial = (Serial) handle; Serial serial = (Serial) handle;

View File

@ -68,7 +68,7 @@ Filename *platform_default_filename(const char *name)
char *get_ttymode(void *frontend, const char *mode) { return NULL; } char *get_ttymode(void *frontend, const char *mode) { return NULL; }
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen) int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{ {
int ret; int ret;
ret = cmdline_get_passwd_input(p, in, inlen); ret = cmdline_get_passwd_input(p, in, inlen);
@ -120,7 +120,7 @@ struct RFile {
int fd; int fd;
}; };
RFile *open_existing_file(char *name, uint64 *size, RFile *open_existing_file(const char *name, uint64 *size,
unsigned long *mtime, unsigned long *atime, unsigned long *mtime, unsigned long *atime,
long *perms) long *perms)
{ {
@ -174,7 +174,7 @@ struct WFile {
char *name; char *name;
}; };
WFile *open_new_file(char *name, long perms) WFile *open_new_file(const char *name, long perms)
{ {
int fd; int fd;
WFile *ret; WFile *ret;
@ -192,7 +192,7 @@ WFile *open_new_file(char *name, long perms)
} }
WFile *open_existing_wfile(char *name, uint64 *size) WFile *open_existing_wfile(const char *name, uint64 *size)
{ {
int fd; int fd;
WFile *ret; WFile *ret;
@ -298,7 +298,7 @@ uint64 get_file_posn(WFile *f)
return ret; return ret;
} }
int file_type(char *name) int file_type(const char *name)
{ {
struct stat statbuf; struct stat statbuf;
@ -321,7 +321,7 @@ struct DirHandle {
DIR *dir; DIR *dir;
}; };
DirHandle *open_directory(char *name) DirHandle *open_directory(const char *name)
{ {
DIR *dir; DIR *dir;
DirHandle *ret; DirHandle *ret;
@ -356,7 +356,7 @@ void close_directory(DirHandle *dir)
sfree(dir); sfree(dir);
} }
int test_wildcard(char *name, int cmdline) int test_wildcard(const char *name, int cmdline)
{ {
struct stat statbuf; struct stat statbuf;
@ -390,7 +390,7 @@ struct WildcardMatcher {
glob_t globbed; glob_t globbed;
int i; int i;
}; };
WildcardMatcher *begin_wildcard_matching(char *name) { WildcardMatcher *begin_wildcard_matching(const char *name) {
WildcardMatcher *ret = snew(WildcardMatcher); WildcardMatcher *ret = snew(WildcardMatcher);
if (glob(name, 0, NULL, &ret->globbed) < 0) { if (glob(name, 0, NULL, &ret->globbed) < 0) {
@ -413,7 +413,7 @@ void finish_wildcard_matching(WildcardMatcher *dir) {
sfree(dir); sfree(dir);
} }
int vet_filename(char *name) int vet_filename(const char *name)
{ {
if (strchr(name, '/')) if (strchr(name, '/'))
return FALSE; return FALSE;
@ -424,12 +424,12 @@ int vet_filename(char *name)
return TRUE; return TRUE;
} }
int create_directory(char *name) int create_directory(const char *name)
{ {
return mkdir(name, 0777) == 0; return mkdir(name, 0777) == 0;
} }
char *dir_file_cat(char *dir, char *file) char *dir_file_cat(const char *dir, const char *file)
{ {
return dupcat(dir, "/", file, NULL); return dupcat(dir, "/", file, NULL);
} }
@ -559,7 +559,7 @@ int ssh_sftp_loop_iteration(void)
/* /*
* Read a PSFTP command line from stdin. * Read a PSFTP command line from stdin.
*/ */
char *ssh_sftp_get_cmdline(char *prompt, int no_fds_ok) char *ssh_sftp_get_cmdline(const char *prompt, int no_fds_ok)
{ {
char *buf; char *buf;
int buflen, bufsize, ret; int buflen, bufsize, ret;

View File

@ -57,7 +57,7 @@ int mb_to_wc(int codepage, int flags, const char *mbstr, int mblen,
} }
int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen, int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
char *mbstr, int mblen, char *defchr, int *defused, char *mbstr, int mblen, const char *defchr, int *defused,
struct unicode_data *ucsdata) struct unicode_data *ucsdata)
{ {
/* FIXME: we should remove the defused param completely... */ /* FIXME: we should remove the defused param completely... */

View File

@ -304,7 +304,8 @@ static void console_data_untrusted(HANDLE hout, const char *data, int len)
WriteFile(hout, data, len, &dummy, NULL); WriteFile(hout, data, len, &dummy, NULL);
} }
int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen) int console_get_userpass_input(prompts_t *p,
const unsigned char *in, int inlen)
{ {
HANDLE hin, hout; HANDLE hin, hout;
size_t curr_prompt; size_t curr_prompt;

View File

@ -2406,7 +2406,7 @@ void dlg_beep(void *dlg)
MessageBeep(0); MessageBeep(0);
} }
void dlg_error_msg(void *dlg, char *msg) void dlg_error_msg(void *dlg, const char *msg)
{ {
struct dlgparam *dp = (struct dlgparam *)dlg; struct dlgparam *dp = (struct dlgparam *)dlg;
MessageBox(dp->hwnd, msg, MessageBox(dp->hwnd, msg,

View File

@ -1126,7 +1126,7 @@ void set_raw_mouse_mode(void *frontend, int activate)
/* /*
* Print a message box and close the connection. * Print a message box and close the connection.
*/ */
void connection_fatal(void *frontend, char *fmt, ...) void connection_fatal(void *frontend, const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *stuff, morestuff[100]; char *stuff, morestuff[100];
@ -1148,7 +1148,7 @@ void connection_fatal(void *frontend, char *fmt, ...)
/* /*
* Report an error at the command-line parsing stage. * Report an error at the command-line parsing stage.
*/ */
void cmdline_error(char *fmt, ...) void cmdline_error(const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *stuff, morestuff[100]; char *stuff, morestuff[100];
@ -2165,7 +2165,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
unsigned int sessno = ((lParam - IDM_SAVED_MIN) unsigned int sessno = ((lParam - IDM_SAVED_MIN)
/ MENU_SAVED_STEP) + 1; / MENU_SAVED_STEP) + 1;
if (sessno < (unsigned)sesslist.nsessions) { if (sessno < (unsigned)sesslist.nsessions) {
char *session = sesslist.sessions[sessno]; const char *session = sesslist.sessions[sessno];
cl = dupprintf("putty @%s", session); cl = dupprintf("putty @%s", session);
inherit_handles = FALSE; inherit_handles = FALSE;
freecl = TRUE; freecl = TRUE;
@ -5345,7 +5345,7 @@ void optimised_move(void *frontend, int to, int from, int lines)
/* /*
* Print a message box and perform a fatal exit. * Print a message box and perform a fatal exit.
*/ */
void fatalbox(char *fmt, ...) void fatalbox(const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *stuff, morestuff[100]; char *stuff, morestuff[100];
@ -5362,7 +5362,7 @@ void fatalbox(char *fmt, ...)
/* /*
* Print a modal (Really Bad) message box and perform a fatal exit. * Print a modal (Really Bad) message box and perform a fatal exit.
*/ */
void modalfatalbox(char *fmt, ...) void modalfatalbox(const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *stuff, morestuff[100]; char *stuff, morestuff[100];
@ -5380,7 +5380,7 @@ void modalfatalbox(char *fmt, ...)
/* /*
* Print a message box and don't close the connection. * Print a message box and don't close the connection.
*/ */
void nonfatal(char *fmt, ...) void nonfatal(const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *stuff, morestuff[100]; char *stuff, morestuff[100];
@ -5787,7 +5787,7 @@ int from_backend_eof(void *frontend)
return TRUE; /* do respond to incoming EOF with outgoing */ return TRUE; /* do respond to incoming EOF with outgoing */
} }
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen) int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{ {
int ret; int ret;
ret = cmdline_get_passwd_input(p, in, inlen); ret = cmdline_get_passwd_input(p, in, inlen);

View File

@ -355,7 +355,7 @@ static Ssh_gss_stat ssh_sspi_display_status(struct ssh_gss_library *lib,
Ssh_gss_ctx ctx, Ssh_gss_buf *buf) Ssh_gss_ctx ctx, Ssh_gss_buf *buf)
{ {
winSsh_gss_ctx *winctx = (winSsh_gss_ctx *) ctx; winSsh_gss_ctx *winctx = (winSsh_gss_ctx *) ctx;
char *msg; const char *msg;
if (winctx == NULL) return SSH_GSS_FAILURE; if (winctx == NULL) return SSH_GSS_FAILURE;

View File

@ -239,7 +239,7 @@ static FILE *debug_fp = NULL;
static HANDLE debug_hdl = INVALID_HANDLE_VALUE; static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
static int debug_got_console = 0; static int debug_got_console = 0;
void dputs(char *buf) void dputs(const char *buf)
{ {
DWORD dw; DWORD dw;

View File

@ -50,7 +50,7 @@ struct SockAddrStep_tag {
struct Socket_tag { struct Socket_tag {
const struct socket_function_table *fn; const struct socket_function_table *fn;
/* the above variable absolutely *must* be the first in this structure */ /* the above variable absolutely *must* be the first in this structure */
char *error; const char *error;
SOCKET s; SOCKET s;
Plug plug; Plug plug;
bufchain output_data; bufchain output_data;
@ -356,7 +356,7 @@ static int errstring_compare(void *av, void *bv)
static tree234 *errstrings = NULL; static tree234 *errstrings = NULL;
char *winsock_error_string(int error) const char *winsock_error_string(int error)
{ {
const char prefix[] = "Network error: "; const char prefix[] = "Network error: ";
struct errstring *es; struct errstring *es;
@ -1162,8 +1162,8 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
return (Socket) ret; return (Socket) ret;
} }
Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, Socket sk_newlistener(const char *srcaddr, int port, Plug plug,
int orig_address_family) int local_host_only, int orig_address_family)
{ {
static const struct socket_function_table fn_table = { static const struct socket_function_table fn_table = {
sk_tcp_plug, sk_tcp_plug,

View File

@ -27,7 +27,7 @@ static char *cmdline_keyfile = NULL;
/* /*
* Print a modal (Really Bad) message box and perform a fatal exit. * Print a modal (Really Bad) message box and perform a fatal exit.
*/ */
void modalfatalbox(char *fmt, ...) void modalfatalbox(const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *stuff; char *stuff;
@ -44,7 +44,7 @@ void modalfatalbox(char *fmt, ...)
/* /*
* Print a non-fatal message box and do not exit. * Print a non-fatal message box and do not exit.
*/ */
void nonfatal(char *fmt, ...) void nonfatal(const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *stuff; char *stuff;
@ -1372,7 +1372,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
case WM_HELP: case WM_HELP:
{ {
int id = ((LPHELPINFO)lParam)->iCtrlId; int id = ((LPHELPINFO)lParam)->iCtrlId;
char *topic = NULL; const char *topic = NULL;
switch (id) { switch (id) {
case IDC_GENERATING: case IDC_GENERATING:
case IDC_PROGRESS: case IDC_PROGRESS:

View File

@ -70,7 +70,7 @@ static int initial_menuitems_count;
/* /*
* Print a modal (Really Bad) message box and perform a fatal exit. * Print a modal (Really Bad) message box and perform a fatal exit.
*/ */
void modalfatalbox(char *fmt, ...) void modalfatalbox(const char *fmt, ...)
{ {
va_list ap; va_list ap;
char *buf; char *buf;
@ -594,7 +594,7 @@ static int CALLBACK KeyListProc(HWND hwnd, UINT msg,
case WM_HELP: case WM_HELP:
{ {
int id = ((LPHELPINFO)lParam)->iCtrlId; int id = ((LPHELPINFO)lParam)->iCtrlId;
char *topic = NULL; const char *topic = NULL;
switch (id) { switch (id) {
case 100: topic = WINHELP_CTX_pageant_keylist; break; case 100: topic = WINHELP_CTX_pageant_keylist; break;
case 101: topic = WINHELP_CTX_pageant_addkey; break; case 101: topic = WINHELP_CTX_pageant_addkey; break;
@ -989,7 +989,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
/* /*
* Fork and Exec the command in cmdline. [DBW] * Fork and Exec the command in cmdline. [DBW]
*/ */
void spawn_cmd(char *cmdline, char * args, int show) void spawn_cmd(const char *cmdline, const char *args, int show)
{ {
if (ShellExecute(NULL, _T("open"), cmdline, if (ShellExecute(NULL, _T("open"), cmdline,
args, NULL, show) <= (HINSTANCE) 32) { args, NULL, show) <= (HINSTANCE) 32) {
@ -1023,7 +1023,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
{ {
WNDCLASS wndclass; WNDCLASS wndclass;
MSG msg; MSG msg;
char *command = NULL; const char *command = NULL;
int added_keys = 0; int added_keys = 0;
int argc, i; int argc, i;
char **argv, **argstart; char **argv, **argstart;

View File

@ -21,7 +21,7 @@ struct agent_callback {
int len; int len;
}; };
void fatalbox(char *p, ...) void fatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");
@ -35,7 +35,7 @@ void fatalbox(char *p, ...)
} }
cleanup_exit(1); cleanup_exit(1);
} }
void modalfatalbox(char *p, ...) void modalfatalbox(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");
@ -49,7 +49,7 @@ void modalfatalbox(char *p, ...)
} }
cleanup_exit(1); cleanup_exit(1);
} }
void nonfatal(char *p, ...) void nonfatal(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "ERROR: "); fprintf(stderr, "ERROR: ");
@ -58,7 +58,7 @@ void nonfatal(char *p, ...)
va_end(ap); va_end(ap);
fputc('\n', stderr); fputc('\n', stderr);
} }
void connection_fatal(void *frontend, char *p, ...) void connection_fatal(void *frontend, const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "FATAL ERROR: "); fprintf(stderr, "FATAL ERROR: ");
@ -72,7 +72,7 @@ void connection_fatal(void *frontend, char *p, ...)
} }
cleanup_exit(1); cleanup_exit(1);
} }
void cmdline_error(char *p, ...) void cmdline_error(const char *p, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "plink: "); fprintf(stderr, "plink: ");
@ -145,7 +145,7 @@ int from_backend_eof(void *frontend_handle)
return FALSE; /* do not respond to incoming EOF with outgoing */ return FALSE; /* do not respond to incoming EOF with outgoing */
} }
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen) int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{ {
int ret; int ret;
ret = cmdline_get_passwd_input(p, in, inlen); ret = cmdline_get_passwd_input(p, in, inlen);

View File

@ -16,7 +16,7 @@
Socket make_handle_socket(HANDLE send_H, HANDLE recv_H, Plug plug, Socket make_handle_socket(HANDLE send_H, HANDLE recv_H, Plug plug,
int overlapped); int overlapped);
Socket platform_new_connection(SockAddr addr, char *hostname, Socket platform_new_connection(SockAddr addr, const char *hostname,
int port, int privport, int port, int privport,
int oobinline, int nodelay, int keepalive, int oobinline, int nodelay, int keepalive,
Plug plug, Conf *conf) Plug plug, Conf *conf)

View File

@ -199,7 +199,7 @@ static const char *serial_configure(Serial serial, HANDLE serport, Conf *conf)
* freed by the caller. * freed by the caller.
*/ */
static const char *serial_init(void *frontend_handle, void **backend_handle, static const char *serial_init(void *frontend_handle, void **backend_handle,
Conf *conf, char *host, int port, Conf *conf, const char *host, int port,
char **realhost, int nodelay, int keepalive) char **realhost, int nodelay, int keepalive)
{ {
Serial serial; Serial serial;
@ -302,7 +302,7 @@ static void serial_reconfig(void *handle, Conf *conf)
/* /*
* Called to send data down the serial connection. * Called to send data down the serial connection.
*/ */
static int serial_send(void *handle, char *buf, int len) static int serial_send(void *handle, const char *buf, int len)
{ {
Serial serial = (Serial) handle; Serial serial = (Serial) handle;

View File

@ -11,7 +11,7 @@
char *get_ttymode(void *frontend, const char *mode) { return NULL; } char *get_ttymode(void *frontend, const char *mode) { return NULL; }
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen) int get_userpass_input(prompts_t *p, const unsigned char *in, int inlen)
{ {
int ret; int ret;
ret = cmdline_get_passwd_input(p, in, inlen); ret = cmdline_get_passwd_input(p, in, inlen);
@ -87,7 +87,7 @@ struct RFile {
HANDLE h; HANDLE h;
}; };
RFile *open_existing_file(char *name, uint64 *size, RFile *open_existing_file(const char *name, uint64 *size,
unsigned long *mtime, unsigned long *atime, unsigned long *mtime, unsigned long *atime,
long *perms) long *perms)
{ {
@ -141,7 +141,7 @@ struct WFile {
HANDLE h; HANDLE h;
}; };
WFile *open_new_file(char *name, long perms) WFile *open_new_file(const char *name, long perms)
{ {
HANDLE h; HANDLE h;
WFile *ret; WFile *ret;
@ -157,7 +157,7 @@ WFile *open_new_file(char *name, long perms)
return ret; return ret;
} }
WFile *open_existing_wfile(char *name, uint64 *size) WFile *open_existing_wfile(const char *name, uint64 *size)
{ {
HANDLE h; HANDLE h;
WFile *ret; WFile *ret;
@ -239,7 +239,7 @@ uint64 get_file_posn(WFile *f)
return ret; return ret;
} }
int file_type(char *name) int file_type(const char *name)
{ {
DWORD attr; DWORD attr;
attr = GetFileAttributes(name); attr = GetFileAttributes(name);
@ -257,7 +257,7 @@ struct DirHandle {
char *name; char *name;
}; };
DirHandle *open_directory(char *name) DirHandle *open_directory(const char *name)
{ {
HANDLE h; HANDLE h;
WIN32_FIND_DATA fdat; WIN32_FIND_DATA fdat;
@ -316,7 +316,7 @@ void close_directory(DirHandle *dir)
sfree(dir); sfree(dir);
} }
int test_wildcard(char *name, int cmdline) int test_wildcard(const char *name, int cmdline)
{ {
HANDLE fh; HANDLE fh;
WIN32_FIND_DATA fdat; WIN32_FIND_DATA fdat;
@ -364,7 +364,7 @@ static char *stripslashes(char *str, int local)
return str; return str;
} }
WildcardMatcher *begin_wildcard_matching(char *name) WildcardMatcher *begin_wildcard_matching(const char *name)
{ {
HANDLE h; HANDLE h;
WIN32_FIND_DATA fdat; WIN32_FIND_DATA fdat;
@ -424,7 +424,7 @@ void finish_wildcard_matching(WildcardMatcher *dir)
sfree(dir); sfree(dir);
} }
int vet_filename(char *name) int vet_filename(const char *name)
{ {
if (strchr(name, '/') || strchr(name, '\\') || strchr(name, ':')) if (strchr(name, '/') || strchr(name, '\\') || strchr(name, ':'))
return FALSE; return FALSE;
@ -435,12 +435,12 @@ int vet_filename(char *name)
return TRUE; return TRUE;
} }
int create_directory(char *name) int create_directory(const char *name)
{ {
return CreateDirectory(name, NULL) != 0; return CreateDirectory(name, NULL) != 0;
} }
char *dir_file_cat(char *dir, char *file) char *dir_file_cat(const char *dir, const char *file)
{ {
return dupcat(dir, "\\", file, NULL); return dupcat(dir, "\\", file, NULL);
} }
@ -691,7 +691,7 @@ static DWORD WINAPI command_read_thread(void *param)
return 0; return 0;
} }
char *ssh_sftp_get_cmdline(char *prompt, int no_fds_ok) char *ssh_sftp_get_cmdline(const char *prompt, int no_fds_ok)
{ {
int ret; int ret;
struct command_read_ctx actx, *ctx = &actx; struct command_read_ctx actx, *ctx = &actx;

View File

@ -1161,7 +1161,7 @@ void get_unitab(int codepage, wchar_t * unitab, int ftype)
} }
int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen, int wc_to_mb(int codepage, int flags, const wchar_t *wcstr, int wclen,
char *mbstr, int mblen, char *defchr, int *defused, char *mbstr, int mblen, const char *defchr, int *defused,
struct unicode_data *ucsdata) struct unicode_data *ucsdata)
{ {
char *p; char *p;

View File

@ -94,7 +94,7 @@ void filereq_free(filereq *state)
/* Callback function to launch context help. */ /* Callback function to launch context help. */
static VOID CALLBACK message_box_help_callback(LPHELPINFO lpHelpInfo) static VOID CALLBACK message_box_help_callback(LPHELPINFO lpHelpInfo)
{ {
char *context = NULL; const char *context = NULL;
#define CHECK_CTX(name) \ #define CHECK_CTX(name) \
do { \ do { \
if (lpHelpInfo->dwContextId == WINHELP_CTXID_ ## name) \ if (lpHelpInfo->dwContextId == WINHELP_CTXID_ ## name) \

View File

@ -357,7 +357,7 @@ void x11_free_display(struct X11Display *disp)
#define XDM_MAXSKEW 20*60 /* 20 minute clock skew should be OK */ #define XDM_MAXSKEW 20*60 /* 20 minute clock skew should be OK */
static char *x11_verify(unsigned long peer_ip, int peer_port, static const char *x11_verify(unsigned long peer_ip, int peer_port,
tree234 *authtree, char *proto, tree234 *authtree, char *proto,
unsigned char *data, int dlen, unsigned char *data, int dlen,
struct X11FakeAuth **auth_ret) struct X11FakeAuth **auth_ret)