]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Giant const-correctness patch of doom!
authorSimon Tatham <anakin@pobox.com>
Fri, 15 May 2015 10:15:42 +0000 (11:15 +0100)
committerSimon Tatham <anakin@pobox.com>
Fri, 15 May 2015 11:47:44 +0000 (12:47 +0100)
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

65 files changed:
cmdgen.c
cmdline.c
conf.c
config.c
dialog.c
dialog.h
import.c
ldisc.c
ldiscucs.c
logging.c
macosx/osxctrls.m
macosx/osxdlg.m
macosx/osxmain.m
macosx/osxwin.m
misc.c
network.h
proxy.c
proxy.h
pscp.c
psftp.c
psftp.h
putty.h
raw.c
rlogin.c
settings.c
sftp.c
sftp.h
ssh.c
ssh.h
sshbn.c
sshpubk.c
telnet.c
terminal.c
unix/gtkask.c
unix/gtkdlg.c
unix/gtkfont.c
unix/gtkwin.c
unix/unix.h
unix/uxcons.c
unix/uxmisc.c
unix/uxnet.c
unix/uxpgnt.c
unix/uxplink.c
unix/uxproxy.c
unix/uxpterm.c
unix/uxpty.c
unix/uxputty.c
unix/uxser.c
unix/uxsftp.c
unix/uxucs.c
windows/wincons.c
windows/winctrls.c
windows/window.c
windows/wingss.c
windows/winmisc.c
windows/winnet.c
windows/winpgen.c
windows/winpgnt.c
windows/winplink.c
windows/winproxy.c
windows/winser.c
windows/winsftp.c
windows/winucs.c
windows/winutils.c
x11fwd.c

index eefcfda7c0291d72f4c283ac9fab467246f9b19e..4811280b111ada742d67350c68093c0f75fd53bb 100644 (file)
--- a/cmdgen.c
+++ b/cmdgen.c
@@ -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;
     fprintf(stderr, "FATAL ERROR: ");
@@ -102,7 +102,7 @@ void modalfatalbox(char *p, ...)
     cleanup_exit(1);
 }
 
-void nonfatal(char *p, ...)
+void nonfatal(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "ERROR: ");
index 327a585a4580ed0ebada38e63a3059cb8108142a..ee1d31e7580fa30826cda3320eb3881fbbbf3215 100644 (file)
--- a/cmdline.c
+++ b/cmdline.c
@@ -44,15 +44,15 @@ struct cmdline_saved_param_set {
  */
 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) {
        saves[pri].savesize = saves[pri].nsaved + 32;
        saves[pri].params = sresize(saves[pri].params, saves[pri].savesize,
                                    struct cmdline_saved_param);
     }
-    saves[pri].params[saves[pri].nsaved].p = p;
-    saves[pri].params[saves[pri].nsaved].value = value;
+    saves[pri].params[saves[pri].nsaved].p = dupstr(p);
+    saves[pri].params[saves[pri].nsaved].value = dupstr(value);
     saves[pri].nsaved++;
 }
 
@@ -85,8 +85,8 @@ void cmdline_cleanup(void)
  * return means that we aren't capable of processing the prompt and
  * 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;
 
     /*
@@ -125,7 +125,7 @@ int cmdline_get_passwd_input(prompts_t *p, unsigned char *in, int inlen) {
  */
 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) {
        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; \
 } 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;
 
@@ -328,7 +329,8 @@ int cmdline_process_param(char *p, char *value, int need_save, Conf *conf)
         sfree(host);
     }
     if (!strcmp(p, "-m")) {
-       char *filename, *command;
+       const char *filename;
+        char *command;
        int cmdlen, cmdsize;
        FILE *fp;
        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)
 {
     int pri, i;
-    for (pri = 0; pri < NPRIORITIES; pri++)
-       for (i = 0; i < saves[pri].nsaved; i++)
+    for (pri = 0; pri < NPRIORITIES; pri++) {
+       for (i = 0; i < saves[pri].nsaved; i++) {
            cmdline_process_param(saves[pri].params[i].p,
                                  saves[pri].params[i].value, 0, conf);
+            sfree(saves[pri].params[i].p);
+            sfree(saves[pri].params[i].value);
+        }
+        saves[pri].nsaved = 0;
+    }
 }
diff --git a/conf.c b/conf.c
index e80f5853ad9437d6069a4205eacef2cb04f510fa..92341758abf89f5de29b7794b03b0a2230c1e968 100644 (file)
--- a/conf.c
+++ b/conf.c
@@ -39,6 +39,16 @@ struct key {
     } 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 {
     union {
        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
  * 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 *subkeyin, char **subkeyout)
 {
-    struct key key;
+    struct constkey key;
     struct conf_entry *entry;
 
     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);
     } else {
        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)
        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)
 {
-    struct key key;
+    struct constkey key;
     struct conf_entry *entry;
     int index;
 
@@ -315,7 +348,8 @@ char *conf_get_str_nthstrkey(Conf *conf, int primary, int n)
     assert(valuetypes[primary] == TYPE_STR);
     key.primary = primary;
     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)
        return NULL;
     entry = index234(conf->tree, index + n);
index a134e326c4f9c0ef4b1d8b636d81bdf46498061c..ded510956a7a7305a1db4df40bfb1bc4e51b53d9 100644 (file)
--- a/config.c
+++ b/config.c
@@ -356,7 +356,7 @@ static void cipherlist_handler(union control *ctrl, void *dlg,
     if (event == EVENT_REFRESH) {
        int i;
 
-       static const struct { char *s; int c; } ciphers[] = {
+       static const struct { const char *s; int c; } ciphers[] = {
            { "3DES",                   CIPHER_3DES },
            { "Blowfish",               CIPHER_BLOWFISH },
            { "DES",                    CIPHER_DES },
@@ -372,7 +372,7 @@ static void cipherlist_handler(union control *ctrl, void *dlg,
        for (i = 0; i < CIPHER_MAX; i++) {
            int c = conf_get_int_int(conf, CONF_ssh_cipherlist, i);
            int j;
-           char *cstr = NULL;
+           const char *cstr = NULL;
            for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
                if (ciphers[j].c == c) {
                    cstr = ciphers[j].s;
@@ -428,7 +428,7 @@ static void kexlist_handler(union control *ctrl, void *dlg,
     if (event == EVENT_REFRESH) {
        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 14",        KEX_DHGROUP14 },
            { "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++) {
            int k = conf_get_int_int(conf, CONF_ssh_kexlist, i);
            int j;
-           char *kstr = NULL;
+           const char *kstr = NULL;
            for (j = 0; j < (sizeof kexes) / (sizeof kexes[0]); j++) {
                if (kexes[j].k == k) {
                    kstr = kexes[j].s;
@@ -472,7 +472,7 @@ static void printerbox_handler(union control *ctrl, void *dlg,
     if (event == EVENT_REFRESH) {
        int nprinters, i;
        printer_enum *pe;
-       char *printer;
+       const char *printer;
 
        dlg_update_start(ctrl, dlg);
        /*
@@ -1119,7 +1119,8 @@ static void portfwd_handler(union control *ctrl, void *dlg,
        }
     } else if (event == EVENT_ACTION) {
        if (ctrl == pfd->addbutton) {
-           char *family, *type, *src, *key, *val;
+           const char *family, *type;
+            char *src, *key, *val;
            int whichbutton;
 
 #ifndef NO_IPV6
@@ -1178,7 +1179,8 @@ static void portfwd_handler(union control *ctrl, void *dlg,
            if (i < 0) {
                dlg_beep(dlg);
            } else {
-               char *key, *val, *p;
+               char *key, *p;
+                const char *val;
 
                key = conf_get_str_nthstrkey(conf, CONF_portfwd, i);
                if (key) {
@@ -1450,7 +1452,7 @@ void setup_config_box(struct controlbox *b, int midsession,
      * logging can sensibly be available.
      */
     {
-       char *sshlogname, *sshrawlogname;
+       const char *sshlogname, *sshrawlogname;
        if ((midsession && protocol == PROT_SSH) ||
            (!midsession && backend_from_proto(PROT_SSH))) {
            sshlogname = "SSH packets";
@@ -1927,7 +1929,7 @@ void setup_config_box(struct controlbox *b, int midsession,
 #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:";
                s = ctrl_getset(b, "Connection", "identity",
index cc1987751e0ef32aa507f3b4e641b13127c87d99..31a9627be1c86f1e9fbe63883c7213b105c7a14a 100644 (file)
--- a/dialog.c
+++ b/dialog.c
@@ -13,7 +13,7 @@
 #include "putty.h"
 #include "dialog.h"
 
-int ctrl_path_elements(char *path)
+int ctrl_path_elements(const char *path)
 {
     int i = 1;
     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,
  * 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;
     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
  * 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;
 
@@ -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
  * 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)
        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. */
 struct controlset *ctrl_settitle(struct controlbox *b,
-                                char *path, char *title)
+                                const char *path, const char *title)
 {
     
     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. */
-struct controlset *ctrl_getset(struct controlbox *b,
-                              char *path, char *name, char *boxtitle)
+struct controlset *ctrl_getset(struct controlbox *b, const char *path,
+                               const char *name, const char *boxtitle)
 {
     struct controlset *s;
     int index = ctrl_find_set(b, path, 1);
@@ -257,8 +257,8 @@ union control *ctrl_columns(struct controlset *s, int ncolumns, ...)
     return c;
 }
 
-union control *ctrl_editbox(struct controlset *s, char *label, char shortcut,
-                           int percentage,
+union control *ctrl_editbox(struct controlset *s, const char *label,
+                            char shortcut, int percentage,
                            intorptr helpctx, handler_fn handler,
                            intorptr context, intorptr context2)
 {
@@ -272,8 +272,8 @@ union control *ctrl_editbox(struct controlset *s, char *label, char shortcut,
     return c;
 }
 
-union control *ctrl_combobox(struct controlset *s, char *label, char shortcut,
-                            int percentage,
+union control *ctrl_combobox(struct controlset *s, const char *label,
+                             char shortcut, int percentage,
                             intorptr helpctx, handler_fn handler,
                             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'
  * 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,
                                 handler_fn handler, intorptr context, ...)
 {
@@ -339,9 +339,9 @@ union control *ctrl_radiobuttons(struct controlset *s, char *label,
     return c;
 }
 
-union control *ctrl_pushbutton(struct controlset *s,char *label,char shortcut,
-                              intorptr helpctx, handler_fn handler,
-                              intorptr context)
+union control *ctrl_pushbutton(struct controlset *s, const char *label,
+                               char shortcut, intorptr helpctx,
+                               handler_fn handler, intorptr context)
 {
     union control *c = ctrl_new(s, CTRL_BUTTON, helpctx, handler, context);
     c->button.label = label ? dupstr(label) : NULL;
@@ -351,9 +351,9 @@ union control *ctrl_pushbutton(struct controlset *s,char *label,char shortcut,
     return c;
 }
 
-union control *ctrl_listbox(struct controlset *s,char *label,char shortcut,
-                           intorptr helpctx, handler_fn handler,
-                           intorptr context)
+union control *ctrl_listbox(struct controlset *s, const char *label,
+                            char shortcut, intorptr helpctx,
+                            handler_fn handler, intorptr context)
 {
     union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
     c->listbox.label = label ? dupstr(label) : NULL;
@@ -368,8 +368,8 @@ union control *ctrl_listbox(struct controlset *s,char *label,char shortcut,
     return c;
 }
 
-union control *ctrl_droplist(struct controlset *s, char *label, char shortcut,
-                            int percentage, intorptr helpctx,
+union control *ctrl_droplist(struct controlset *s, const char *label,
+                             char shortcut, int percentage, intorptr helpctx,
                             handler_fn handler, intorptr 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;
 }
 
-union control *ctrl_draglist(struct controlset *s,char *label,char shortcut,
-                            intorptr helpctx, handler_fn handler,
-                            intorptr context)
+union control *ctrl_draglist(struct controlset *s, const char *label,
+                             char shortcut, intorptr helpctx,
+                             handler_fn handler, intorptr context)
 {
     union control *c = ctrl_new(s, CTRL_LISTBOX, helpctx, handler, context);
     c->listbox.label = label ? dupstr(label) : NULL;
@@ -402,10 +402,10 @@ union control *ctrl_draglist(struct controlset *s,char *label,char shortcut,
     return c;
 }
 
-union control *ctrl_filesel(struct controlset *s,char *label,char shortcut,
-                           char const *filter, int write, char *title,
-                           intorptr helpctx, handler_fn handler,
-                           intorptr context)
+union control *ctrl_filesel(struct controlset *s, const char *label,
+                            char shortcut, const char *filter, int write,
+                            const char *title, intorptr helpctx,
+                            handler_fn handler, intorptr context)
 {
     union control *c = ctrl_new(s, CTRL_FILESELECT, helpctx, handler, context);
     c->fileselect.label = label ? dupstr(label) : NULL;
@@ -416,9 +416,9 @@ union control *ctrl_filesel(struct controlset *s,char *label,char shortcut,
     return c;
 }
 
-union control *ctrl_fontsel(struct controlset *s,char *label,char shortcut,
-                           intorptr helpctx, handler_fn handler,
-                           intorptr context)
+union control *ctrl_fontsel(struct controlset *s, const char *label,
+                            char shortcut, intorptr helpctx,
+                            handler_fn handler, intorptr context)
 {
     union control *c = ctrl_new(s, CTRL_FONTSELECT, helpctx, handler, context);
     c->fontselect.label = label ? dupstr(label) : NULL;
@@ -433,16 +433,17 @@ union control *ctrl_tabdelay(struct controlset *s, union control *ctrl)
     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));
     c->text.label = dupstr(text);
     return c;
 }
 
-union control *ctrl_checkbox(struct controlset *s, char *label, char shortcut,
-                            intorptr helpctx, handler_fn handler,
-                            intorptr context)
+union control *ctrl_checkbox(struct controlset *s, const char *label,
+                             char shortcut, intorptr helpctx,
+                             handler_fn handler, intorptr context)
 {
     union control *c = ctrl_new(s, CTRL_CHECKBOX, helpctx, handler, context);
     c->checkbox.label = label ? dupstr(label) : NULL;
index 6775167019e886ccda93c3649386375ad9323410..9ac355c64afcab78279aa88db966d25969b15184 100644 (file)
--- a/dialog.h
+++ b/dialog.h
@@ -458,10 +458,10 @@ void ctrl_free_box(struct controlbox *);
 
 /* Set up a panel title. */
 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. */
-struct controlset *ctrl_getset(struct controlbox *,
-                              char *path, char *name, char *boxtitle);
+struct controlset *ctrl_getset(struct controlbox *, const char *path,
+                               const char *name, const char *boxtitle);
 void ctrl_free_set(struct controlset *);
 
 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. */
 union control *ctrl_columns(struct controlset *, int ncolumns, ...);
-union control *ctrl_editbox(struct controlset *, char *label, char shortcut,
-                           int percentage, intorptr helpctx,
+union control *ctrl_editbox(struct controlset *, const char *label,
+                            char shortcut, int percentage, intorptr helpctx,
                            handler_fn handler,
                            intorptr context, intorptr context2);
-union control *ctrl_combobox(struct controlset *, char *label, char shortcut,
-                            int percentage, intorptr helpctx,
+union control *ctrl_combobox(struct controlset *, const char *label,
+                             char shortcut, int percentage, intorptr helpctx,
                             handler_fn handler,
                             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'
  * is NO_SHORTCUT.
  */
-union control *ctrl_radiobuttons(struct controlset *, char *label,
-                                char shortcut, int ncolumns,
-                                intorptr helpctx,
+union control *ctrl_radiobuttons(struct controlset *, const char *label,
+                                char shortcut, int ncolumns, intorptr helpctx,
                                 handler_fn handler, intorptr context, ...);
-union control *ctrl_pushbutton(struct controlset *,char *label,char shortcut,
-                              intorptr helpctx,
+union control *ctrl_pushbutton(struct controlset *, const char *label,
+                               char shortcut, intorptr helpctx,
                               handler_fn handler, intorptr context);
-union control *ctrl_listbox(struct controlset *,char *label,char shortcut,
-                           intorptr helpctx,
+union control *ctrl_listbox(struct controlset *, const char *label,
+                            char shortcut, intorptr helpctx,
                            handler_fn handler, intorptr context);
-union control *ctrl_droplist(struct controlset *, char *label, char shortcut,
-                            int percentage, intorptr helpctx,
+union control *ctrl_droplist(struct controlset *, const char *label,
+                             char shortcut, int percentage, intorptr helpctx,
                             handler_fn handler, intorptr context);
-union control *ctrl_draglist(struct controlset *,char *label,char shortcut,
-                            intorptr helpctx,
+union control *ctrl_draglist(struct controlset *, const char *label,
+                             char shortcut, intorptr helpctx,
                             handler_fn handler, intorptr context);
-union control *ctrl_filesel(struct controlset *,char *label,char shortcut,
-                           char const *filter, int write, char *title,
-                           intorptr helpctx,
+union control *ctrl_filesel(struct controlset *, const char *label,
+                            char shortcut, const char *filter, int write,
+                            const char *title, intorptr helpctx,
                            handler_fn handler, intorptr context);
-union control *ctrl_fontsel(struct controlset *,char *label,char shortcut,
-                           intorptr helpctx,
+union control *ctrl_fontsel(struct controlset *, const char *label,
+                            char shortcut, intorptr helpctx,
                            handler_fn handler, intorptr context);
-union control *ctrl_text(struct controlset *, char *text, intorptr helpctx);
-union control *ctrl_checkbox(struct controlset *, char *label, char shortcut,
-                            intorptr helpctx,
+union control *ctrl_text(struct controlset *, const char *text,
+                         intorptr helpctx);
+union control *ctrl_checkbox(struct controlset *, const char *label,
+                             char shortcut, intorptr helpctx,
                             handler_fn handler, intorptr context);
 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.
  */
 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
  * processing is completed, and passes an integer value (typically
@@ -647,8 +647,8 @@ void dlg_refresh(union control *ctrl, void *dlg);
  *          ... process this controlset ...
  *      }
  */
-int ctrl_find_path(struct controlbox *b, char *path, int index);
-int ctrl_path_elements(char *path);
+int ctrl_find_path(struct controlbox *b, const char *path, int index);
+int ctrl_path_elements(const char *path);
 /* Return the number of matching path elements at the starts of p1 and p2,
  * 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);
index ed57add09fc85186bc331b5aab2bdd3255d9b70b..1e91f82adeefa230c3f7df59cadf32a4d70165e0 100644 (file)
--- a/import.c
+++ b/import.c
@@ -362,7 +362,8 @@ static struct openssh_pem_key *load_openssh_pem_key(const Filename *filename,
     struct openssh_pem_key *ret;
     FILE *fp = NULL;
     char *line = NULL;
-    char *errmsg, *p;
+    const char *errmsg;
+    char *p;
     int headers_done;
     char base64_bit[4];
     int base64_chars = 0;
@@ -570,7 +571,7 @@ struct ssh2_userkey *openssh_pem_read(const Filename *filename,
     int ret, id, len, flags;
     int i, num_integers;
     struct ssh2_userkey *retval = NULL;
-    char *errmsg;
+    const char *errmsg;
     unsigned char *blob;
     int blobsize = 0, blobptr, privptr;
     char *modptr = NULL;
@@ -910,7 +911,7 @@ int openssh_pem_write(const Filename *filename, struct ssh2_userkey *key,
     int outlen;
     struct mpint_pos numbers[9];
     int nnumbers, pos, len, seqlen, i;
-    char *header, *footer;
+    const char *header, *footer;
     char zero[1];
     unsigned char iv[8];
     int ret = 0;
@@ -1283,7 +1284,8 @@ static struct openssh_new_key *load_openssh_new_key(const Filename *filename,
     struct openssh_new_key *ret;
     FILE *fp = NULL;
     char *line = NULL;
-    char *errmsg, *p;
+    const char *errmsg;
+    char *p;
     char base64_bit[4];
     int base64_chars = 0;
     const void *filedata;
@@ -1526,7 +1528,7 @@ struct ssh2_userkey *openssh_new_read(const Filename *filename,
     struct ssh2_userkey *retkey;
     int i;
     struct ssh2_userkey *retval = NULL;
-    char *errmsg;
+    const char *errmsg;
     unsigned char *blob;
     int blobsize = 0;
     unsigned checkint0, checkint1;
@@ -1981,7 +1983,8 @@ static struct sshcom_key *load_sshcom_key(const Filename *filename,
     FILE *fp;
     char *line = NULL;
     int hdrstart, len;
-    char *errmsg, *p;
+    const char *errmsg;
+    char *p;
     int headers_done;
     char base64_bit[4];
     int base64_chars = 0;
@@ -2226,7 +2229,7 @@ struct ssh2_userkey *sshcom_read(const Filename *filename, char *passphrase,
                                 const char **errmsg_p)
 {
     struct sshcom_key *key = load_sshcom_key(filename, errmsg_p);
-    char *errmsg;
+    const char *errmsg;
     int pos, len;
     const char prefix_rsa[] = "if-modn{sign{rsa";
     const char prefix_dsa[] = "dl-modp{sign{dsa";
@@ -2470,7 +2473,7 @@ int sshcom_write(const Filename *filename, struct ssh2_userkey *key,
     int outlen;
     struct mpint_pos numbers[6];
     int nnumbers, initial_zero, pos, lenpos, i;
-    char *type;
+    const char *type;
     char *ciphertext;
     int cipherlen;
     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 += 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));
     }
     lenpos = pos;                     /* remember this position */
diff --git a/ldisc.c b/ldisc.c
index 0e864874efcb0b9908693d90bc67078d9bc4fab7..320a93607c3cb6204732bf0e4889e4a9db9e32ba 100644 (file)
--- a/ldisc.c
+++ b/ldisc.c
@@ -22,7 +22,7 @@
                       (ldisc->back->ldisc(ldisc->backhandle, 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);
 }
@@ -134,7 +134,7 @@ void ldisc_echoedit_update(void *handle)
     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;
     int keyflag = 0;
index fe0da8a6ae25217ca1eab4110b6ce2a584d155e0..1634bc43fd603520927dce87b558f720ef8cbf92 100644 (file)
@@ -13,7 +13,7 @@
 #include "ldisc.h"
 
 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;
     wchar_t *widebuffer = 0;
@@ -34,7 +34,7 @@ void lpage_send(void *handle,
     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;
     int ratio = (in_utf(ldisc->term))?3:1;
index 26634f7738bb5d3beb0ba87306f780fc9e586e7b..899fa27becc9748dfcdacabc4e0d7071eb4e8fd9 100644 (file)
--- a/logging.c
+++ b/logging.c
@@ -233,7 +233,7 @@ void log_eventlog(void *handle, const char *event)
  * Set of blanking areas must be in increasing order.
  */
 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,
                const unsigned long *seq,
                 unsigned downstream_id, const char *additional_log_text)
index b4270f9d4c38a011a7212ccfea3509e210da0728..27c2c52bac6da661b235135586185c4d0cc12aaf 100644 (file)
@@ -1736,7 +1736,7 @@ void dlg_beep(void *dv)
     NSBeep();
 }
 
-void dlg_error_msg(void *dv, char *msg)
+void dlg_error_msg(void *dv, const char *msg)
 {
     /* FIXME */
 }
index 0940781963739b638a50b6fa3831b7f78f47101b..84a761fe68e0ea873c4c6c48b38abedf51aa7c62 100644 (file)
@@ -490,7 +490,7 @@ static void connection_fatal_callback(void *ctx, int result)
     [win endSession:FALSE];
 }
 
-void connection_fatal(void *frontend, char *p, ...)
+void connection_fatal(void *frontend, const char *p, ...)
 {
     SessionWindow *win = (SessionWindow *)frontend;
     va_list ap;
index 2eba150c39a5160f5964b4c0634359d31c7ff200..2ac772a835aa2883b984e1214fd1cfc9f9981604 100644 (file)
@@ -58,7 +58,7 @@ char *x_get_default(const char *key)
     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];
     NSAlert *alert;
@@ -85,7 +85,7 @@ static void commonfatalbox(char *p, va_list ap)
     exit(1);
 }
 
-void nonfatal(void *frontend, char *p, ...)
+void nonfatal(void *frontend, const char *p, ...)
 {
     char *errorbuf;
     NSAlert *alert;
@@ -103,7 +103,7 @@ void nonfatal(void *frontend, char *p, ...)
     sfree(errorbuf);
 }
 
-void fatalbox(char *p, ...)
+void fatalbox(const char *p, ...)
 {
     va_list ap;
     va_start(ap, p);
@@ -111,7 +111,7 @@ void fatalbox(char *p, ...)
     va_end(ap);
 }
 
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
 {
     va_list ap;
     va_start(ap, p);
@@ -119,7 +119,7 @@ void modalfatalbox(char *p, ...)
     va_end(ap);
 }
 
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "%s: ", appname);
index 3bf85cd842bd2fdf450e83c4c277f8b30a4702e7..062913694b06cfbdf9101d0212a1dec6c08d1fa3 100644 (file)
@@ -888,7 +888,7 @@ int from_backend_untrusted(void *frontend, const char *data, int 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;
     Terminal *term = [win term];
diff --git a/misc.c b/misc.c
index c6587ab1e96eb21563683c3cc55e2d0ecec300dd..37c0207ef79251a98f90a4e398a92d9460039716 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -175,7 +175,7 @@ int main(void)
     return fails != 0 ? 1 : 0;
 }
 /* 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; }
 char *conf_get_str(Conf *conf, int primary) { return NULL; }
 #endif /* TEST_HOST_STRFOO */
@@ -830,7 +830,7 @@ void safefree(void *ptr)
  */
 
 #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, ...)
 {
index 675d24c7c5575f3e20e52b7822321f5e157af683..ec67ba942345f9b15d5f3813c856942bd6f80667 100644 (file)
--- a/network.h
+++ b/network.h
@@ -92,20 +92,20 @@ struct plug_function_table {
 /* proxy indirection layer */
 /* NB, control of 'addr' is passed via new_connection, which takes
  * responsibility for freeing it */
-Socket new_connection(SockAddr addr, char *hostname,
+Socket new_connection(SockAddr addr, const char *hostname,
                      int port, int privport,
                      int oobinline, int nodelay, int keepalive,
                      Plug plug, Conf *conf);
-Socket new_listener(char *srcaddr, int port, Plug plug, int local_host_only,
-                   Conf *conf, int addressfamily);
-SockAddr name_lookup(char *host, int port, char **canonicalname,
+Socket new_listener(const char *srcaddr, int port, Plug plug,
+                    int local_host_only, Conf *conf, int addressfamily);
+SockAddr name_lookup(const char *host, int port, char **canonicalname,
                     Conf *conf, int addressfamily);
 int proxy_for_destination (SockAddr addr, const char *hostname, int port,
                            Conf *conf);
 
 /* platform-dependent callback from 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 oobinline, int nodelay, int keepalive,
                               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,
              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_close(s) (((*s)->close) (s))
diff --git a/proxy.c b/proxy.c
index e2201c643f80579e4b5dd3aa52310442ed53f469..423ed8da492eac154f2e725a3a2a9cdc6f828332 100644 (file)
--- a/proxy.c
+++ b/proxy.c
@@ -362,7 +362,7 @@ int proxy_for_destination (SockAddr addr, const char *hostname,
     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)
 {
     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);
 }
 
-Socket new_connection(SockAddr addr, char *hostname,
+Socket new_connection(SockAddr addr, const char *hostname,
                      int port, int privport,
                      int oobinline, int nodelay, int keepalive,
                      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);
 }
 
-Socket new_listener(char *srcaddr, int port, Plug plug, int local_host_only,
-                   Conf *conf, int addressfamily)
+Socket new_listener(const char *srcaddr, int port, Plug plug,
+                    int local_host_only, Conf *conf, int addressfamily)
 {
     /* TODO: SOCKS (and potentially others) support inbound
      * TODO: connections via the proxy. support them.
diff --git a/proxy.h b/proxy.h
index 12b47e16de88d3860faee4ab6d7639a07f77e780..2e2324c078343ae5d2229a79e5b08d20659b10d0 100644 (file)
--- a/proxy.h
+++ b/proxy.h
@@ -19,7 +19,7 @@ struct Socket_proxy_tag {
     const struct socket_function_table *fn;
     /* the above variable absolutely *must* be the first in this structure */
 
-    char * error;
+    const char *error;
 
     Socket sub_socket;
     Plug plug;
diff --git a/pscp.c b/pscp.c
index 50ab90b5e1922d9c5075b5b4b71a0ab3d4bbd6eb..1d4967e760bbecdd2ae72b1674901d7073738383 100644 (file)
--- a/pscp.c
+++ b/pscp.c
@@ -48,9 +48,9 @@ static void *backhandle;
 static Conf *conf;
 int sent_eof = FALSE;
 
-static void source(char *src);
-static void rsource(char *src);
-static void sink(char *targ, char *src);
+static void source(const char *src);
+static void rsource(const char *src);
+static void sink(const char *targ, const char *src);
 
 const char *const appname = "PSCP";
 
@@ -62,12 +62,12 @@ const char *const appname = "PSCP";
 
 void ldisc_echoedit_update(void *handle) { }
 
-static void tell_char(FILE * stream, char c)
+static void tell_char(FILE *stream, char c)
 {
     fputc(c, stream);
 }
 
-static void tell_str(FILE * stream, char *str)
+static void tell_str(FILE *stream, const char *str)
 {
     unsigned int i;
 
@@ -75,7 +75,7 @@ static void tell_str(FILE * stream, char *str)
        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;
     va_list ap;
@@ -91,7 +91,7 @@ static void tell_user(FILE * stream, char *fmt, ...)
 /*
  *  Print an error message and perform a fatal exit.
  */
-void fatalbox(char *fmt, ...)
+void fatalbox(const char *fmt, ...)
 {
     char *str, *str2;
     va_list ap;
@@ -106,7 +106,7 @@ void fatalbox(char *fmt, ...)
 
     cleanup_exit(1);
 }
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
 {
     char *str, *str2;
     va_list ap;
@@ -121,7 +121,7 @@ void modalfatalbox(char *fmt, ...)
 
     cleanup_exit(1);
 }
-void nonfatal(char *fmt, ...)
+void nonfatal(const char *fmt, ...)
 {
     char *str, *str2;
     va_list ap;
@@ -134,7 +134,7 @@ void nonfatal(char *fmt, ...)
     sfree(str2);
     errs++;
 }
-void connection_fatal(void *frontend, char *fmt, ...)
+void connection_fatal(void *frontend, const char *fmt, ...)
 {
     char *str, *str2;
     va_list ap;
@@ -302,7 +302,7 @@ static void ssh_scp_init(void)
 /*
  *  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;
     va_list ap;
@@ -533,7 +533,7 @@ static void do_cmd(char *host, char *user, char *cmd)
 /*
  *  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)
 {
     float ratebs;
@@ -608,8 +608,13 @@ static char *colon(char *str)
 /*
  * Return a pointer to the portion of str that comes after the last
  * 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;
 
@@ -626,7 +631,7 @@ static char *stripslashes(char *str, int local)
        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;
     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_names *names;
@@ -791,7 +796,7 @@ static struct fxp_handle *scp_sftp_filehandle;
 static struct fxp_xfer *scp_sftp_xfer;
 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) {
        /*
@@ -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) {
        char *fullname;
@@ -1012,7 +1017,7 @@ void scp_restore_remotepath(char *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) {
        char *fullname;
@@ -1087,7 +1092,7 @@ int scp_send_enddir(void)
  * right at the start, whereas scp_sink_init is called to
  * 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) {
        char *newsource;
@@ -1657,12 +1662,12 @@ static void run_err(const char *fmt, ...)
 /*
  *  Execute the source part of the SCP protocol.
  */
-static void source(char *src)
+static void source(const char *src)
 {
     uint64 size;
     unsigned long mtime, atime;
     long permissions;
-    char *last;
+    const char *last;
     RFile *f;
     int attr;
     uint64 i;
@@ -1682,7 +1687,7 @@ static void source(char *src)
            /*
             * Avoid . and .. directories.
             */
-           char *p;
+           const char *p;
            p = strrchr(src, '/');
            if (!p)
                p = strrchr(src, '\\');
@@ -1770,9 +1775,9 @@ static void source(char *src)
 /*
  *  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;
     DirHandle *dir;
 
@@ -1814,7 +1819,7 @@ static void rsource(char *src)
 /*
  * 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;
     int targisdir = 0;
@@ -2020,23 +2025,26 @@ static void sink(char *targ, char *src)
  */
 static void toremote(int argc, char *argv[])
 {
-    char *src, *targ, *host, *user;
+    char *src, *wtarg, *host, *user;
+    const char *targ;
     char *cmd;
     int i, wc_type;
 
     uploading = 1;
 
-    targ = argv[argc - 1];
+    wtarg = argv[argc - 1];
 
     /* Separate host from filename */
-    host = targ;
-    targ = colon(targ);
-    if (targ == NULL)
-       bump("targ == NULL in toremote()");
-    *targ++ = '\0';
-    if (*targ == '\0')
-       targ = ".";
+    host = wtarg;
+    wtarg = colon(wtarg);
+    if (wtarg == NULL)
+       bump("wtarg == NULL in toremote()");
+    *wtarg++ = '\0';
     /* Substitute "." for empty target */
+    if (*wtarg == '\0')
+       targ = ".";
+    else
+        targ = wtarg;
 
     /* Separate host and username */
     user = host;
@@ -2112,7 +2120,8 @@ static void toremote(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;
 
     uploading = 0;
@@ -2120,18 +2129,20 @@ static void tolocal(int argc, char *argv[])
     if (argc != 2)
        bump("More than one remote source not supported");
 
-    src = argv[0];
+    wsrc = argv[0];
     targ = argv[1];
 
     /* Separate host from filename */
-    host = src;
-    src = colon(src);
-    if (src == NULL)
+    host = wsrc;
+    wsrc = colon(wsrc);
+    if (wsrc == NULL)
        bump("Local to local copy not supported");
-    *src++ = '\0';
-    if (*src == '\0')
-       src = ".";
+    *wsrc++ = '\0';
     /* Substitute "." for empty filename */
+    if (*wsrc == '\0')
+       src = ".";
+    else
+        src = wsrc;
 
     /* Separate username and hostname */
     user = host;
@@ -2164,21 +2175,25 @@ static void tolocal(int argc, char *argv[])
  */
 static void get_dir_list(int argc, char *argv[])
 {
-    char *src, *host, *user;
-    char *cmd, *p, *q;
+    char *wsrc, *host, *user;
+    const char *src;
+    char *cmd, *p;
+    const char *q;
     char c;
 
-    src = argv[0];
+    wsrc = argv[0];
 
     /* Separate host from filename */
-    host = src;
-    src = colon(src);
-    if (src == NULL)
+    host = wsrc;
+    wsrc = colon(wsrc);
+    if (wsrc == NULL)
        bump("Local file listing not supported");
-    *src++ = '\0';
-    if (*src == '\0')
-       src = ".";
+    *wsrc++ = '\0';
     /* Substitute "." for empty filename */
+    if (*wsrc == '\0')
+       src = ".";
+    else
+        src = wsrc;
 
     /* Separate username and hostname */
     user = host;
@@ -2273,7 +2288,7 @@ void version(void)
     cleanup_exit(1);
 }
 
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "pscp: ");
diff --git a/psftp.c b/psftp.c
index a8baad6d2e4aa25a84a1bf886514e85fd37fdde9..e0e027a1abf2894cc3198c59f2cde767e6e6cd5b 100644 (file)
--- a/psftp.c
+++ b/psftp.c
@@ -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_
  * pathname (though it may be ugly, eg /home/simon/../foobar).
  */
-char *canonify(char *name)
+char *canonify(const char *name)
 {
     char *fullname, *canonname;
     struct sftp_packet *pktin;
@@ -77,7 +77,7 @@ char *canonify(char *name)
     if (name[0] == '/') {
        fullname = dupstr(name);
     } else {
-       char *slash;
+       const char *slash;
        if (pwd[strlen(pwd) - 1] == '/')
            slash = "";
        else
@@ -172,8 +172,13 @@ char *canonify(char *name)
 /*
  * Return a pointer to the portion of str that comes after the last
  * 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;
 
@@ -190,7 +195,7 @@ static char *stripslashes(char *str, int local)
        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_name **ournames;
     int nnames, namesize;
-    char *dir, *cdir, *unwcdir, *wildcard;
+    const char *dir;
+    char *cdir, *unwcdir, *wildcard;
     struct sftp_packet *pktin;
     struct sftp_request *req;
     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 struct sftp_cmd_lookup {
-    char *name;
+    const char *name;
     /*
      * 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.
      */
     int listed;                               /* do we list this in primary help? */
-    char *shorthelp;
-    char *longhelp;
+    const char *shorthelp;
+    const char *longhelp;
     int (*obey) (struct sftp_command *);
 } 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;
 
@@ -2450,7 +2456,7 @@ static int verbose = 0;
 /*
  *  Print an error message and perform a fatal exit.
  */
-void fatalbox(char *fmt, ...)
+void fatalbox(const char *fmt, ...)
 {
     char *str, *str2;
     va_list ap;
@@ -2464,7 +2470,7 @@ void fatalbox(char *fmt, ...)
 
     cleanup_exit(1);
 }
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
 {
     char *str, *str2;
     va_list ap;
@@ -2478,7 +2484,7 @@ void modalfatalbox(char *fmt, ...)
 
     cleanup_exit(1);
 }
-void nonfatal(char *fmt, ...)
+void nonfatal(const char *fmt, ...)
 {
     char *str, *str2;
     va_list ap;
@@ -2490,7 +2496,7 @@ void nonfatal(char *fmt, ...)
     fputs(str2, stderr);
     sfree(str2);
 }
-void connection_fatal(void *frontend, char *fmt, ...)
+void connection_fatal(void *frontend, const char *fmt, ...)
 {
     char *str, *str2;
     va_list ap;
@@ -2866,7 +2872,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
     return 0;
 }
 
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "psftp: ");
diff --git a/psftp.h b/psftp.h
index e6ad00f6946f7a09ee56ef6b6d00db0534ce333a..b3022d56068339d81f93a798b0f188a441165f7c 100644 (file)
--- a/psftp.h
+++ b/psftp.h
@@ -45,7 +45,7 @@ int ssh_sftp_loop_iteration(void);
  * FALSE, a back end is not (intentionally) active at all (e.g.
  * 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-
@@ -59,13 +59,13 @@ int psftp_main(int argc, char *argv[]);
  * probably only ever be supported on Windows, so these functions
  * 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,
                      unsigned long done, unsigned long eta,
                      unsigned long ratebs);
 void gui_send_errcount(int list, int errs);
 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
@@ -87,15 +87,15 @@ typedef struct RFile RFile;
 typedef struct WFile WFile;
 /* 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. */
-RFile *open_existing_file(char *name, uint64 *size,
+RFile *open_existing_file(const char *name, uint64 *size,
                          unsigned long *mtime, unsigned long *atime,
                           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 */
 int read_from_file(RFile *f, void *buffer, int length);
 /* Closes and frees the RFile */
 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 */
 int write_to_file(WFile *f, void *buffer, int length);
 void set_file_times(WFile *f, unsigned long mtime, unsigned long atime);
@@ -117,13 +117,13 @@ uint64 get_file_posn(WFile *f);
 enum {
     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.
  */
 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 */
 char *read_filename(DirHandle *dir);
 void close_directory(DirHandle *dir);
@@ -145,13 +145,13 @@ void close_directory(DirHandle *dir);
 enum {
     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.
  */
 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 */
 char *wildcard_get_filename(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.
  */
-int vet_filename(char *name);
+int vet_filename(const char *name);
 
 /*
  * 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
  * 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 */
diff --git a/putty.h b/putty.h
index 60a0b9fca3a2fe2394f57b532645d69ba13a4f56..22ec67b79829f97f6afcac2aad95c518af0ebb61 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -139,7 +139,7 @@ typedef struct terminal_tag Terminal;
 
 struct sesslist {
     int nsessions;
-    char **sessions;
+    const char **sessions;
     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
      * equivalent to each other.
      */
-    char *s;
+    const char *s;
     int v;
 
     /*
@@ -416,13 +416,13 @@ enum {
 
 struct backend_tag {
     const char *(*init) (void *frontend_handle, void **backend_handle,
-                        Conf *conf, char *host, int port, char **realhost,
-                        int nodelay, int keepalive);
+                        Conf *conf, const char *host, int port,
+                         char **realhost, int nodelay, int keepalive);
     void (*free) (void *handle);
     /* back->reconfig() passes in a replacement configuration. */
     void (*reconfig) (void *handle, Conf *conf);
     /* 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 */
     int (*sendbuffer) (void *handle);
     void (*size) (void *handle, int width, int height);
@@ -442,7 +442,7 @@ struct backend_tag {
      */
     void (*unthrottle) (void *handle, int);
     int (*cfg_info) (void *handle);
-    char *name;
+    const char *name;
     int protocol;
     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 optimised_move(void *frontend, int, int, int);
 void set_raw_mouse_mode(void *frontend, int);
-void connection_fatal(void *frontend, char *, ...);
-void nonfatal(char *, ...);
-void fatalbox(char *, ...);
-void modalfatalbox(char *, ...);
+void connection_fatal(void *frontend, const char *, ...);
+void nonfatal(const char *, ...);
+void fatalbox(const char *, ...);
+void modalfatalbox(const char *, ...);
 #ifdef macintosh
 #pragma noreturn(fatalbox)
 #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 = `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
 
 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_proto(int proto);
 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 load_settings(char *section, Conf *conf);
+void load_settings(const char *section, Conf *conf);
 void load_open_settings(void *sesskey, Conf *conf);
 void get_sesslist(struct sesslist *, int allocate);
-void do_defaults(char *, Conf *);
+void do_defaults(const char *, Conf *);
 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);
 char *term_get_ttymode(Terminal *term, const char *mode);
 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);
 
@@ -1026,7 +1026,7 @@ struct logblank_t {
     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,
                const unsigned long *sequence,
                 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_configure(void *, Conf *);
 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);
 
 /*
  * Exports from ldiscucs.c.
  */
-void lpage_send(void *, int codepage, char *buf, int len, int interactive);
-void luni_send(void *, wchar_t * widebuf, int len, int interactive);
+void lpage_send(void *, int codepage, const char *buf, int len,
+                int interactive);
+void luni_send(void *, const wchar_t * widebuf, int len, int interactive);
 
 /*
  * 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,
             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);
 wchar_t xlat_uskbd2cyrllic(int ch);
 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.
  */
 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);
 int is_interactive(void);
 
@@ -1237,16 +1239,21 @@ void printer_finish_job(printer_job *);
  * Exports from cmdline.c (and also cmdline_error(), which is
  * defined differently in various places and required _by_
  * 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_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_NONNETWORK 2
 extern int cmdline_tooltype;
 
-void cmdline_error(char *, ...);
+void cmdline_error(const char *, ...);
 
 /*
  * Exports from config.c.
diff --git a/raw.c b/raw.c
index 97355e8ad768bd38df89bc653736a386c9143c5b..b083d09d59a572c885470b13911b26438b85722b 100644 (file)
--- a/raw.c
+++ b/raw.c
@@ -125,8 +125,8 @@ static void raw_sent(Plug plug, int bufsize)
  */
 static const char *raw_init(void *frontend_handle, void **backend_handle,
                            Conf *conf,
-                           char *host, int port, char **realhost, int nodelay,
-                           int keepalive)
+                           const char *host, int port, char **realhost,
+                            int nodelay, int keepalive)
 {
     static const struct plug_function_table fn_table = {
        raw_log,
@@ -214,7 +214,7 @@ static void raw_reconfig(void *handle, Conf *conf)
 /*
  * 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;
 
index 3c86eee8575f20981ae725ed22fe71ef6ec334c7..10cda463ed81cf8d2c796130c9c91a0899dd3dc6 100644 (file)
--- a/rlogin.c
+++ b/rlogin.c
@@ -161,7 +161,7 @@ static void rlogin_startup(Rlogin rlogin, const char *ruser)
  */
 static const char *rlogin_init(void *frontend_handle, void **backend_handle,
                               Conf *conf,
-                              char *host, int port, char **realhost,
+                              const char *host, int port, char **realhost,
                               int nodelay, int keepalive)
 {
     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.
  */
-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;
 
index b3f7a4db2cf885560024dc1f9df10841133835b1..6b770eeeec98631846c496cfcc83a04f3155f783 100644 (file)
@@ -124,13 +124,14 @@ static void gppfile(void *handle, const char *name, Conf *conf, int primary)
     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);
     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));
 }
@@ -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
  * 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;
 
@@ -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,
                  int include_values)
 {
-    char *buf, *p, *q, *key, *realkey, *val;
+    char *buf, *p, *key, *realkey;
+    const char *val, *q;
     int len;
 
     len = 1;                          /* allow for NUL */
@@ -298,7 +300,7 @@ static const char *val2key(const struct keyvalwhere *mapping,
  * to the end and duplicates are weeded.
  * 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,
                   Conf *conf, int primary)
 {
@@ -384,7 +386,7 @@ static void gprefs(void *sesskey, char *name, char *def,
 /* 
  * 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,
                   Conf *conf, int primary)
 {
@@ -418,7 +420,7 @@ static void wprefs(void *sesskey, char *name,
     sfree(buf);
 }
 
-char *save_settings(char *section, Conf *conf)
+char *save_settings(const char *section, Conf *conf)
 {
     void *sesskey;
     char *errmsg;
@@ -434,7 +436,7 @@ char *save_settings(char *section, Conf *conf)
 void save_open_settings(void *sesskey, Conf *conf)
 {
     int i;
-    char *p;
+    const char *p;
 
     write_setting_i(sesskey, "Present", 1);
     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);
 }
 
-void load_settings(char *section, Conf *conf)
+void load_settings(const char *section, Conf *conf)
 {
     void *sesskey;
 
@@ -769,7 +771,7 @@ void load_open_settings(void *sesskey, Conf *conf)
         * disable gex under the "bugs" panel after one report of
         * a server which offered it then choked, but we never got
         * a server version string or any other reports. */
-       char *default_kexes;
+       const char *default_kexes;
        i = 2 - gppi_raw(sesskey, "BugDHGEx2", 0);
        if (i == FORCE_ON)
             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);
 }
 
-void do_defaults(char *session, Conf *conf)
+void do_defaults(const char *session, Conf *conf)
 {
     load_settings(session, conf);
 }
@@ -1076,7 +1078,7 @@ void get_sesslist(struct sesslist *list, int allocate)
            p++;
        }
 
-       list->sessions = snewn(list->nsessions + 1, char *);
+       list->sessions = snewn(list->nsessions + 1, const char *);
        list->sessions[0] = "Default Settings";
        p = list->buffer;
        i = 1;
@@ -1088,7 +1090,7 @@ void get_sesslist(struct sesslist *list, int allocate)
            p++;
        }
 
-       qsort(list->sessions, i, sizeof(char *), sessioncmp);
+       qsort(list->sessions, i, sizeof(const char *), sessioncmp);
     } else {
        sfree(list->buffer);
        sfree(list->sessions);
diff --git a/sftp.c b/sftp.c
index bf75779df7e549660eeda4a0a866b05bb8fe5d9b..b4421f779e41dd56085bf5c840defa9594e78948 100644 (file)
--- a/sftp.c
+++ b/sftp.c
@@ -23,7 +23,7 @@ struct sftp_packet {
 static const char *fxp_error_message;
 static int fxp_errtype;
 
-static void fxp_internal_error(char *msg);
+static void fxp_internal_error(const char *msg);
 
 /* ----------------------------------------------------------------------
  * 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);
     }
 }
-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;
     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);
     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));
     PUT_32BIT(pkt->data + pkt->savedpos - 4, pkt->length - pkt->savedpos);
 }
 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);
     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_str(pkt, data);
@@ -438,7 +439,7 @@ static int fxp_got_status(struct sftp_packet *pktin)
        return -1;
 }
 
-static void fxp_internal_error(char *msg)
+static void fxp_internal_error(const char *msg)
 {
     fxp_error_message = msg;
     fxp_errtype = -1;
@@ -501,7 +502,7 @@ int fxp_init(void)
 /*
  * 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_packet *pktout;
@@ -547,7 +548,7 @@ char *fxp_realpath_recv(struct sftp_packet *pktin, struct sftp_request *req)
 /*
  * 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 sftp_request *req = sftp_alloc_request();
@@ -596,7 +597,7 @@ struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin,
 /*
  * 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_packet *pktout;
@@ -662,7 +663,7 @@ void fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req)
     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_packet *pktout;
@@ -688,7 +689,7 @@ int fxp_mkdir_recv(struct sftp_packet *pktin, struct sftp_request *req)
     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_packet *pktout;
@@ -713,7 +714,7 @@ int fxp_rmdir_recv(struct sftp_packet *pktin, struct sftp_request *req)
     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_packet *pktout;
@@ -738,7 +739,8 @@ int fxp_remove_recv(struct sftp_packet *pktin, struct sftp_request *req)
     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_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
  * 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_packet *pktout;
@@ -836,7 +838,8 @@ int fxp_fstat_recv(struct sftp_packet *pktin, struct sftp_request *req,
 /*
  * 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_packet *pktout;
diff --git a/sftp.h b/sftp.h
index c3167a57a0cf3d0619f9a4d7d35a365c37b56f9f..c61340c1582273b9e8e723b60f56b2eeeb548e44 100644 (file)
--- a/sftp.h
+++ b/sftp.h
@@ -125,14 +125,14 @@ int fxp_init(void);
  * Canonify a pathname. Concatenate the two given path elements
  * 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);
 
 /*
  * Open a file. 'attrs' contains attributes to be applied to the file
  * 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_handle *fxp_open_recv(struct sftp_packet *pktin,
                                 struct sftp_request *req);
@@ -140,7 +140,7 @@ struct fxp_handle *fxp_open_recv(struct sftp_packet *pktin,
 /*
  * 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 sftp_request *req);
 
@@ -153,31 +153,32 @@ void fxp_close_recv(struct sftp_packet *pktin, struct sftp_request *req);
 /*
  * 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);
 
 /*
  * 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);
 
 /*
  * 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);
 
 /*
  * 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);
 
 /*
  * 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,
                  struct fxp_attrs *attrs);
 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.
  */
-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);
 struct sftp_request *fxp_fsetstat_send(struct fxp_handle *handle,
                                       struct fxp_attrs attrs);
diff --git a/ssh.c b/ssh.c
index fd3cdd64bcd0ac7d1b2a50d666e10da71d32b7e0..616b87d3220f124f8bf6bdc0fdf705dc21bd06ae 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -189,7 +189,7 @@ static unsigned int ssh_tty_parse_boolean(char *s)
 #define translate(x) if (type == x) 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
-static char *ssh1_pkt_type(int type)
+static const char *ssh1_pkt_type(int type)
 {
     translate(SSH1_MSG_DISCONNECT);
     translate(SSH1_SMSG_PUBLIC_KEY);
@@ -234,7 +234,8 @@ static char *ssh1_pkt_type(int type)
     translate(SSH1_CMSG_AUTH_CCARD_RESPONSE);
     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_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 void ssh2_pkt_send(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);
-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);
 static void ssh2_channel_check_close(struct ssh_channel *c);
 static void ssh_channel_destroy(struct ssh_channel *c);
@@ -686,11 +687,11 @@ struct Packet {
     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);
-static void ssh2_protocol(Ssh ssh, void *vin, int inlen,
+static void ssh2_protocol(Ssh ssh, const void *vin, int inlen,
                          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);
 static void ssh1_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_special(void *handle, Telnet_Special);
 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 ssh2_set_window(struct ssh_channel *c, int newwin);
 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 void ssh_pkt_getstring(struct Packet *pkt, char **p, int *length);
 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);
 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 */
     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 *(*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);
 
     /*
@@ -936,7 +939,7 @@ struct ssh_tag {
     unsigned long max_data_size;
     int kex_in_progress;
     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.
@@ -1294,7 +1297,8 @@ static void ssh1_log_outgoing_packet(Ssh ssh, struct Packet *pkt)
  * Update the *data and *datalen variables.
  * 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;
 
@@ -1549,7 +1553,8 @@ static void ssh2_log_outgoing_packet(Ssh ssh, struct Packet *pkt)
     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;
 
@@ -1837,7 +1842,8 @@ static struct Packet *ssh2_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
     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)
 {
     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);
 }
 
-static int ssh_versioncmp(char *a, char *b)
+static int ssh_versioncmp(const char *a, const char *b)
 {
     char *ae, *be;
     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,
-                                     unsigned char **data, int *datalen)
+                                     const unsigned char **data, int *datalen)
 {
     struct Packet *pktin;
 
@@ -3255,7 +3261,7 @@ static void ssh_process_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);
     *data += *datalen;
@@ -3265,7 +3271,7 @@ static void ssh_queue_incoming_data(Ssh ssh,
 static void ssh_process_queued_incoming_data(Ssh ssh)
 {
     void *vdata;
-    unsigned char *data;
+    const unsigned char *data;
     int len, origlen;
 
     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;
 }
 
-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. */
     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
  * 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)
 {
     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;
     Ssh ssh = c->ssh;
-    void *sentreply = reply;
+    const void *sentreply = reply;
 
     c->u.a.outstanding_requests--;
     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
  * => 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)
 {
     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.
  */
-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)
 {
     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;
-       char *cipher_string = NULL;
+       const char *cipher_string = NULL;
        int i;
        for (i = 0; !cipher_chosen && i < CIPHER_MAX; i++) {
            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();
 }
 
-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)
 {
     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;
 }
 
-static void ssh1_protocol(Ssh ssh, void *vin, int inlen,
+static void ssh1_protocol(Ssh ssh, const void *vin, int inlen,
                          struct Packet *pktin)
 {
-    unsigned char *in=(unsigned char*)vin;
+    const unsigned char *in = (const unsigned char *)vin;
     if (ssh->state == SSH_STATE_CLOSED)
        return;
 
@@ -6149,10 +6156,10 @@ static void ssh2_mkkey(Ssh ssh, Bignum K, unsigned char *H, char chr,
 /*
  * 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)
 {
-    unsigned char *in = (unsigned char *)vin;
+    const unsigned char *in = (const unsigned char *)vin;
     struct do_ssh2_transport_state {
        int crLine;
        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.
      */
     {
-       char *str, *preferred;
+       char *str;
+        const char *preferred;
        int i, j, len;
 
        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.
  */
-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)
 {
     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.
  */
-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;
 
@@ -7508,7 +7517,8 @@ static void ssh2_queue_chanreq_handler(struct ssh_channel *c,
  * the server initiated channel closure before we saw the response)
  * 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)
 {
     struct Packet *pktout;
@@ -8218,7 +8228,7 @@ static void ssh2_msg_channel_request(Ssh ssh, struct Packet *pktin)
                   !memcmp(type, "exit-signal", 11)) {
 
            int is_plausible = TRUE, is_int = FALSE;
-           char *fmt_sig = "", *fmt_msg = "";
+            char *fmt_sig = NULL, *fmt_msg = NULL;
            char *msg;
            int msglen = 0, core = FALSE;
            /* 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 */
            } /* else don't attempt to parse */
            logeventf(ssh, "Server exited on signal%s%s%s",
-                     fmt_sig, core ? " (core dumped)" : "",
-                     fmt_msg);
-           if (*fmt_sig) sfree(fmt_sig);
-           if (*fmt_msg) sfree(fmt_msg);
+                     fmt_sig ? fmt_sig : "",
+                      core ? " (core dumped)" : "",
+                     fmt_msg ? fmt_msg : "");
+           sfree(fmt_sig);
+            sfree(fmt_msg);
            reply = SSH2_MSG_CHANNEL_SUCCESS;
 
        }
@@ -8416,7 +8427,7 @@ static void ssh2_msg_channel_open(Ssh ssh, struct Packet *pktin)
     char *peeraddr;
     int peeraddrlen;
     int peerport;
-    char *error = NULL;
+    const char *error = NULL;
     struct ssh_channel *c;
     unsigned remid, winsize, pktsize;
     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);
 }
 
-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 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 */
                    
                    {
-                       char *msg;
+                       const char *msg;
                        if (changereq_first_time)
                            msg = "Server requested password change";
                        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)
 {
-    unsigned char *in = (unsigned char *)vin;
+    const unsigned char *in = (const unsigned char *)vin;
     if (ssh->state == SSH_STATE_CLOSED)
        return;
 
@@ -10763,10 +10774,10 @@ static void ssh2_protocol(Ssh ssh, void *vin, int inlen,
        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)
 {
-    unsigned char *in = (unsigned char *)vin;
+    const unsigned char *in = (const unsigned char *)vin;
     if (ssh->state == SSH_STATE_CLOSED)
        return;
 
@@ -10787,7 +10798,8 @@ static void ssh_cache_conf_values(Ssh ssh)
  * Returns an error message, or NULL on success.
  */
 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)
 {
     const char *p;
@@ -11039,7 +11051,8 @@ static void ssh_free(void *handle)
 static void ssh_reconfig(void *handle, Conf *conf)
 {
     Ssh ssh = (Ssh) handle;
-    char *rekeying = NULL, rekey_mandatory = FALSE;
+    const char *rekeying = NULL;
+    int rekey_mandatory = FALSE;
     unsigned long old_max_data_size;
     int i, rekey_time;
 
@@ -11104,14 +11117,14 @@ static void ssh_reconfig(void *handle, Conf *conf)
 /*
  * 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;
 
     if (ssh == NULL || ssh->s == NULL || ssh->protocol == NULL)
        return 0;
 
-    ssh->protocol(ssh, (unsigned char *)buf, len, 0);
+    ssh->protocol(ssh, (const unsigned char *)buf, len, 0);
 
     return ssh_sendbuffer(ssh);
 }
@@ -11319,7 +11332,7 @@ static void ssh_special(void *handle, Telnet_Special code)
        }
     } else {
        /* Is is a POSIX signal? */
-       char *signame = NULL;
+       const char *signame = NULL;
        if (code == TS_SIGABRT) signame = "ABRT";
        if (code == TS_SIGALRM) signame = "ALRM";
        if (code == TS_SIGFPE)  signame = "FPE";
@@ -11436,7 +11449,8 @@ static void ssh_unthrottle(void *handle, int bufsize)
     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;
     Ssh ssh = c->ssh;
diff --git a/ssh.h b/ssh.h
index 4fc4edeae986daf7ae2cc12cd0f847e07e152c76..0b6b4f8ebc9aab85ce0bd45e28214b6bab043173 100644 (file)
--- a/ssh.h
+++ b/ssh.h
@@ -304,7 +304,7 @@ struct ssh2_cipher {
     void (*setkey) (void *, unsigned char *key);/* for SSH-2 */
     void (*encrypt) (void *, unsigned char *blk, int len);
     void (*decrypt) (void *, unsigned char *blk, int len);
-    char *name;
+    const char *name;
     int blksize;
     int keylen;
     unsigned int flags;
@@ -343,7 +343,7 @@ struct ssh_hash {
 };   
 
 struct ssh_kex {
-    char *name, *groupname;
+    const char *name, *groupname;
     enum { KEXTYPE_DH, KEXTYPE_RSA, KEXTYPE_ECDH } main_type;
     const struct ssh_hash *hash;
     const void *extra;                 /* private to the kex methods */
@@ -388,10 +388,10 @@ struct ssh_signkey {
 };
 
 struct ssh_compress {
-    char *name;
+    const char *name;
     /* For zlib@openssh.com: if non-NULL, this name will be considered once
      * userauth has completed successfully. */
-    char *delayed_name;
+    const char *delayed_name;
     void *(*compress_init) (void);
     void (*compress_cleanup) (void *);
     int (*compress) (void *, unsigned char *block, int len,
@@ -478,7 +478,8 @@ struct PortForwarding;
 
 /* Allocate and register a new channel for port forwarding */
 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 */
 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(const struct ssh_signkey *alg, void *data);
 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_target_type(int type);
diff --git a/sshbn.c b/sshbn.c
index 0d64620da5c8728b59adf86e3334148cc76359bb..a35bf31444a23e788e1fb09fa16e7d4d7b2861c9 100644 (file)
--- a/sshbn.c
+++ b/sshbn.c
@@ -1970,7 +1970,7 @@ char *bignum_decimal(Bignum x)
  * testdata/bignum.py .
  */
 
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "FATAL ERROR: ");
index 30f9e4b331c78b2121c131d59134dbc595c7a282..0323335ee0bfb0e98ae18de25538627bb8313e7b 100644 (file)
--- a/sshpubk.c
+++ b/sshpubk.c
@@ -1308,7 +1308,7 @@ int ssh2_save_userkey(const Filename *filename, struct ssh2_userkey *key,
     int passlen;
     int cipherblk;
     int i;
-    char *cipherstr;
+    const char *cipherstr;
     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
  * messages.
  */
-char *key_type_to_str(int type)
+const char *key_type_to_str(int type)
 {
     switch (type) {
       case SSH_KEYTYPE_UNOPENABLE: return "unable to open file"; break;
index 8717a9723d3689c3dd9a97304c6b9b3cdbdc09f4..ca1665258c61429384135c619aa7c6989f270d91 100644 (file)
--- a/telnet.c
+++ b/telnet.c
@@ -113,7 +113,7 @@ enum { TELOPTS(telnet_enum) dummy=0 };
        ( (x) != IAC && \
              (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;
     switch (opt) {
@@ -212,14 +212,14 @@ typedef struct telnet_tag {
 
 #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;
     backlog = from_backend(telnet->frontend, 0, buf, len);
     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;
     /*
@@ -715,7 +715,7 @@ static void telnet_sent(Plug plug, int bufsize)
  * freed by the caller.
  */
 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)
 {
     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.
  */
-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;
     unsigned char *p, *end;
index d4808e7fbe652ea7f6008a0dde8e5ade3f1c307c..dc727238a8236a7644b5e88469dc3fed7f8456e7 100644 (file)
@@ -65,7 +65,7 @@
 
 #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 };
 
@@ -3940,7 +3940,8 @@ static void term_out(Terminal *term)
 
                            switch (term->esc_args[0]) {
                                int x, y, len;
-                               char buf[80], *p;
+                               char buf[80];
+                                const char *p;
                              case 1:
                                set_iconic(term->frontend, FALSE);
                                break;
@@ -6319,7 +6320,7 @@ void term_set_focus(Terminal *term, int has_focus)
  */
 char *term_get_ttymode(Terminal *term, const char *mode)
 {
-    char *val = NULL;
+    const char *val = NULL;
     if (strcmp(mode, "ERASE") == 0) {
        val = term->bksp_is_delete ? "^?" : "^H";
     }
@@ -6339,7 +6340,7 @@ struct term_userpass_state {
  * input.
  */
 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;
     if (!s) {
index 7d0f13cf9f9657503fe3827a3f6ca277783f6f02..0f62e9b80418aa1f47e8e400bbcbac1d50323ca7 100644 (file)
@@ -342,7 +342,7 @@ char *gtk_askpass_main(const char *display, const char *wintitle,
 }
 
 #ifdef TEST_ASKPASS
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "FATAL ERROR: ");
index 8007b75c85265824081f501a15e1bb6052df6a16..6c532024c488febf3b6784ad4d064f1a3d5cf00a 100644 (file)
@@ -1055,7 +1055,7 @@ static void set_transient_window_pos(GtkWidget *parent, GtkWidget *child)
     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;
     GtkWidget *window, *hbox, *text, *ok;
@@ -1998,7 +1998,7 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
             {
                 GtkWidget *ww;
                 GtkRequisition req;
-                char *browsebtn =
+                const char *browsebtn =
                     (ctrl->generic.type == CTRL_FILESELECT ?
                      "Browse..." : "Change...");
 
@@ -3138,7 +3138,8 @@ static void messagebox_handler(union control *ctrl, void *dlg,
     if (event == EVENT_ACTION)
        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;
     struct controlbox *ctrlbox;
@@ -3235,7 +3236,7 @@ int messagebox(GtkWidget *parentwin, char *title, char *msg, int minwid, ...)
     return dp.retval;
 }
 
-int string_width(char *text)
+int string_width(const char *text)
 {
     GtkWidget *label = gtk_label_new(text);
     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,
                string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"),
                "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,
                string_width("REASONABLY LONG LINE OF TEXT FOR BASIC SANITY"),
                "OK", 'o', 1, 1, NULL);
 }
 
-void fatalbox(char *p, ...)
+void fatalbox(const char *p, ...)
 {
     va_list ap;
     char *msg;
@@ -3381,7 +3382,7 @@ void fatalbox(char *p, ...)
     cleanup_exit(1);
 }
 
-void nonfatal(char *p, ...)
+void nonfatal(const char *p, ...)
 {
     va_list ap;
     char *msg;
@@ -3404,7 +3405,7 @@ static void licence_clicked(GtkButton *button, gpointer data)
 {
     char *title;
 
-    char *licence =
+    const char *licence =
        "Copyright 1997-2015 Simon Tatham.\n\n"
 
        "Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
index d241db0e8960d9604806a9bd43bba2644e4ce812..d776dfa5b56128c298cf41cf956249cb35ec133c 100644 (file)
@@ -175,7 +175,7 @@ static char *x11_guess_derived_font_name(XFontStruct *xfs, int bold, int wide)
     if (XGetFontProperty(xfs, fontprop, &ret)) {
        char *name = XGetAtomName(disp, (Atom)ret);
        if (name && name[0] == '-') {
-           char *strings[13];
+           const char *strings[13];
            char *dupname, *extrafree = NULL, *ret;
            char *p, *q;
            int nstr;
index f3a17d58434c2fdb1453fac5ea2ce95e794ce227..e8345881cd803d391da8aa1ccf6fdca7433bd99f 100644 (file)
@@ -133,7 +133,7 @@ struct draw_ctx {
 
 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 exit_callback(void *vinst);
@@ -143,7 +143,7 @@ char *x_get_default(const char *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;
 
@@ -221,7 +221,7 @@ int from_backend_eof(void *frontend)
     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;
     int ret;
@@ -885,7 +885,7 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
         * NetHack keypad mode.
         */
        if (nethack_mode) {
-           char *keys = NULL;
+           const char *keys = NULL;
            switch (event->keyval) {
              case GDK_KP_1: case GDK_KP_End: keys = "bB\002"; 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;
 }
 
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "FATAL ERROR: ");
@@ -2614,7 +2614,7 @@ void modalfatalbox(char *p, ...)
     exit(1);
 }
 
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
 {
     va_list ap;
     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; }
 
     while (--argc > 0) {
-       char *p = *++argv;
+       const char *p = *++argv;
         int ret;
 
        /*
index 79a9fb3cf2efd3800027721ac6e2398d366d630e..aba8a2bd46d985176a2d8c04b5a327f449fd2898 100644 (file)
@@ -84,21 +84,22 @@ void *get_window(void *frontend);      /* void * to avoid depending on gtk.h */
 /* Things pterm.c needs from gtkdlg.c */
 int do_config_box(const char *title, Conf *conf,
                  int midsession, int protcfginfo);
-void fatal_message_box(void *window, char *msg);
-void nonfatal_message_box(void *window, char *msg);
+void fatal_message_box(void *window, const char *msg);
+void nonfatal_message_box(void *window, const char *msg);
 void about_box(void *window);
 void *eventlogstuff_new(void);
 void showeventlog(void *estuff, void *parentwin);
 void logevent_dlg(void *estuff, const char *string);
 int reallyclose(void *frontend);
 #ifdef MAY_REFER_TO_GTK_IN_HEADERS
-int messagebox(GtkWidget *parentwin, char *title, char *msg, int minwid, ...);
-int string_width(char *text);
+int messagebox(GtkWidget *parentwin, const char *title,
+               const char *msg, int minwid, ...);
+int string_width(const char *text);
 #endif
 
 /* Things pterm.c needs from {ptermm,uxputty}.c */
 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 */
 int keysym_to_unicode(int keysym);
index ea6297c4980382c753ceb835bc5b8fcf2f90b0d6..eabb7769dddc0a3284018c0efe2a8fa4ed3edd73 100644 (file)
@@ -364,7 +364,8 @@ static void console_prompt_text(FILE *outfp, const char *data, int len)
     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;
     FILE *outfp = NULL;
index 95133a0393e4379d93cecb7695f238caeda30328..e2c2de3232e05103fc7e5d8ddd39ee3b8bbde87f 100644 (file)
@@ -98,7 +98,7 @@ Filename *filename_deserialise(void *vdata, int maxsize, int *used)
 #ifdef DEBUG
 static FILE *debug_fp = NULL;
 
-void dputs(char *buf)
+void dputs(const char *buf)
 {
     if (!debug_fp) {
        debug_fp = fopen("debug.log", "w");
index 235d6fd97d039d3ed2f97167e68e4285935981ee..e409315a66a8b808d6463e202b0423f09554a48e 100644 (file)
@@ -776,7 +776,8 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
     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;
 #ifndef NO_IPV6
index bf7377720a80bb96aa5c83a740d532f425efab1c..95646b3e4fafdb2c8dacd48d6954979e2cf0992c 100644 (file)
@@ -23,7 +23,7 @@
 SockAddr unix_sock_addr(const char *path);
 Socket new_unix_listener(SockAddr listenaddr, Plug plug);
 
-void fatalbox(char *p, ...)
+void fatalbox(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "FATAL ERROR: ");
@@ -33,7 +33,7 @@ void fatalbox(char *p, ...)
     fputc('\n', stderr);
     exit(1);
 }
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "FATAL ERROR: ");
@@ -43,7 +43,7 @@ void modalfatalbox(char *p, ...)
     fputc('\n', stderr);
     exit(1);
 }
-void nonfatal(char *p, ...)
+void nonfatal(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "ERROR: ");
@@ -52,7 +52,7 @@ void nonfatal(char *p, ...)
     va_end(ap);
     fputc('\n', stderr);
 }
-void connection_fatal(void *frontend, char *p, ...)
+void connection_fatal(void *frontend, const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "FATAL ERROR: ");
@@ -62,7 +62,7 @@ void connection_fatal(void *frontend, char *p, ...)
     fputc('\n', stderr);
     exit(1);
 }
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "pageant: ");
index 3e32925cd4e182cf54baa1d0a7397bce415adcf7..64c3cabcdacc66afd58e6ec87b9684e14725a863 100644 (file)
@@ -29,7 +29,7 @@ void *logctx;
 
 static struct termios orig_termios;
 
-void fatalbox(char *p, ...)
+void fatalbox(const char *p, ...)
 {
     struct termios cf;
     va_list ap;
@@ -46,7 +46,7 @@ void fatalbox(char *p, ...)
     }
     cleanup_exit(1);
 }
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
 {
     struct termios cf;
     va_list ap;
@@ -63,7 +63,7 @@ void modalfatalbox(char *p, ...)
     }
     cleanup_exit(1);
 }
-void nonfatal(char *p, ...)
+void nonfatal(const char *p, ...)
 {
     struct termios cf;
     va_list ap;
@@ -75,7 +75,7 @@ void nonfatal(char *p, ...)
     fputc('\n', stderr);
     postmsg(&cf);
 }
-void connection_fatal(void *frontend, char *p, ...)
+void connection_fatal(void *frontend, const char *p, ...)
 {
     struct termios cf;
     va_list ap;
@@ -92,7 +92,7 @@ void connection_fatal(void *frontend, char *p, ...)
     }
     cleanup_exit(1);
 }
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
 {
     struct termios cf;
     va_list ap;
@@ -446,7 +446,7 @@ int from_backend_eof(void *frontend_handle)
     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;
     ret = cmdline_get_passwd_input(p, in, inlen);
index dfbcc86a290bdb00ec982fbaffb63fd1cdf3dcc3..f230604a2c41634cec5afe725b99cdff3685c02b 100644 (file)
@@ -230,7 +230,7 @@ static int localproxy_select_result(int fd, int event)
     return 1;
 }
 
-Socket platform_new_connection(SockAddr addr, char *hostname,
+Socket platform_new_connection(SockAddr addr, const char *hostname,
                               int port, int privport,
                               int oobinline, int nodelay, int keepalive,
                               Plug plug, Conf *conf)
index 1f4f20c2aaf363c32a1e2ec4e24d6649ccf1518c..3211d45a54135ac44ef73b8587278b317dd89ff5 100644 (file)
@@ -33,7 +33,7 @@ void cleanup_exit(int 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. */
 }
index 54ba082c3a0e6a74107a1e923c2ff1001d9a418f..84f36ef87bef2c5062829933dd5d48c77c0b11f5 100644 (file)
@@ -706,8 +706,8 @@ static void pty_uxsel_setup(Pty pty)
  * freed by the caller.
  */
 static const char *pty_init(void *frontend, void **backend_handle, Conf *conf,
-                           char *host, int port, char **realhost, int nodelay,
-                           int keepalive)
+                           const char *host, int port, char **realhost,
+                            int nodelay, int keepalive)
 {
     int slavefd;
     pid_t pid, pgrp;
@@ -1008,7 +1008,7 @@ static void pty_try_write(Pty 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;
 
index c7b0fcb2209c05a97db9be7caf7d6d71ec9543ad..f0b4bfbda75b1666946c2b043cf896208c465f04 100644 (file)
@@ -50,9 +50,11 @@ static int got_host = 0;
 
 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) {
         /*
@@ -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
          * 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);
     } 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.
          */
-        p = arg;
+        p = argdup;
         while (*p && !isspace((unsigned char)*p))
             p++;
         if (*p)
@@ -100,6 +102,9 @@ int process_nonoption_arg(char *arg, Conf *conf, int *allow_launch)
     }
     if (got_host)
        *allow_launch = TRUE;
+
+    sfree(argdup);
+
     return 1;
 }
 
index e45f3ae1232a2d21139d9d2f0407acf02289187f..691e527ed143522470f7b1a45270a4170125adc2 100644 (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,
                               Conf *conf,
-                              char *host, int port, char **realhost, int nodelay,
-                              int keepalive)
+                              const char *host, int port, char **realhost,
+                               int nodelay, int keepalive)
 {
     Serial serial;
     const char *err;
@@ -462,7 +462,7 @@ static void serial_try_write(Serial serial)
 /*
  * 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;
 
index 391da02126233abb52e59276a86d3721a9aef92f..21d7f40fb94aa1136d5e7bdb66c083170f8bd66a 100644 (file)
@@ -68,7 +68,7 @@ Filename *platform_default_filename(const char *name)
 
 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;
     ret = cmdline_get_passwd_input(p, in, inlen);
@@ -120,7 +120,7 @@ struct RFile {
     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,
                           long *perms)
 {
@@ -174,7 +174,7 @@ struct WFile {
     char *name;
 };
 
-WFile *open_new_file(char *name, long perms)
+WFile *open_new_file(const char *name, long perms)
 {
     int fd;
     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;
     WFile *ret;
@@ -298,7 +298,7 @@ uint64 get_file_posn(WFile *f)
     return ret;
 }
 
-int file_type(char *name)
+int file_type(const char *name)
 {
     struct stat statbuf;
 
@@ -321,7 +321,7 @@ struct DirHandle {
     DIR *dir;
 };
 
-DirHandle *open_directory(char *name)
+DirHandle *open_directory(const char *name)
 {
     DIR *dir;
     DirHandle *ret;
@@ -356,7 +356,7 @@ void close_directory(DirHandle *dir)
     sfree(dir);
 }
 
-int test_wildcard(char *name, int cmdline)
+int test_wildcard(const char *name, int cmdline)
 {
     struct stat statbuf;
 
@@ -390,7 +390,7 @@ struct WildcardMatcher {
     glob_t globbed;
     int i;
 };
-WildcardMatcher *begin_wildcard_matching(char *name) {
+WildcardMatcher *begin_wildcard_matching(const char *name) {
     WildcardMatcher *ret = snew(WildcardMatcher);
 
     if (glob(name, 0, NULL, &ret->globbed) < 0) {
@@ -413,7 +413,7 @@ void finish_wildcard_matching(WildcardMatcher *dir) {
     sfree(dir);
 }
 
-int vet_filename(char *name)
+int vet_filename(const char *name)
 {
     if (strchr(name, '/'))
        return FALSE;
@@ -424,12 +424,12 @@ int vet_filename(char *name)
     return TRUE;
 }
 
-int create_directory(char *name)
+int create_directory(const char *name)
 {
     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);
 }
@@ -559,7 +559,7 @@ int ssh_sftp_loop_iteration(void)
 /*
  * 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;
     int buflen, bufsize, ret;
index 5d3d5af0924a7caeea823fcf27f058ca73fc3161..86cc33d4f5883573e671ccba74d21706230eab5c 100644 (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,
-            char *mbstr, int mblen, char *defchr, int *defused,
+            char *mbstr, int mblen, const char *defchr, int *defused,
             struct unicode_data *ucsdata)
 {
     /* FIXME: we should remove the defused param completely... */
index a470e74457e997ecd30100e1d003fd0c117bebc5..b0ca5f2e262f0bc54ffac5c28967c396a1ccd84b 100644 (file)
@@ -304,7 +304,8 @@ static void console_data_untrusted(HANDLE hout, const char *data, int len)
     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;
     size_t curr_prompt;
index 9bee927472d5fb36bd7e1a653682bd6cbe99e6ba..ea1cc1825eb6e8adb88ec44b25b876329efde8f6 100644 (file)
@@ -2406,7 +2406,7 @@ void dlg_beep(void *dlg)
     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;
     MessageBox(dp->hwnd, msg,
index 76c0b9280f716a1e37e7cfc3bdca1d8d8920479a..b021b05f0e28d207c02236abfba92b6fdda9d4d4 100644 (file)
@@ -1126,7 +1126,7 @@ void set_raw_mouse_mode(void *frontend, int activate)
 /*
  * 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;
     char *stuff, morestuff[100];
@@ -1148,7 +1148,7 @@ void connection_fatal(void *frontend, char *fmt, ...)
 /*
  * Report an error at the command-line parsing stage.
  */
-void cmdline_error(char *fmt, ...)
+void cmdline_error(const char *fmt, ...)
 {
     va_list ap;
     char *stuff, morestuff[100];
@@ -2165,7 +2165,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
                    unsigned int sessno = ((lParam - IDM_SAVED_MIN)
                                           / MENU_SAVED_STEP) + 1;
                    if (sessno < (unsigned)sesslist.nsessions) {
-                       char *session = sesslist.sessions[sessno];
+                       const char *session = sesslist.sessions[sessno];
                        cl = dupprintf("putty @%s", session);
                        inherit_handles = FALSE;
                        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.
  */
-void fatalbox(char *fmt, ...)
+void fatalbox(const char *fmt, ...)
 {
     va_list ap;
     char *stuff, morestuff[100];
@@ -5362,7 +5362,7 @@ void fatalbox(char *fmt, ...)
 /*
  * Print a modal (Really Bad) message box and perform a fatal exit.
  */
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
 {
     va_list ap;
     char *stuff, morestuff[100];
@@ -5380,7 +5380,7 @@ void modalfatalbox(char *fmt, ...)
 /*
  * Print a message box and don't close the connection.
  */
-void nonfatal(char *fmt, ...)
+void nonfatal(const char *fmt, ...)
 {
     va_list ap;
     char *stuff, morestuff[100];
@@ -5787,7 +5787,7 @@ int from_backend_eof(void *frontend)
     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;
     ret = cmdline_get_passwd_input(p, in, inlen);
index d08064d4bd537534d8b5662c2aaeeb8a87af43e3..0187a5a7c19bde2359cf3ea622550bc8aa1ae276 100644 (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)
 {
     winSsh_gss_ctx *winctx = (winSsh_gss_ctx *) ctx;
-    char *msg;
+    const char *msg;
 
     if (winctx == NULL) return SSH_GSS_FAILURE;
 
index 5bf52141ca7aa1fab834e0d67a559d675cfd481d..d21e1170babbc39ee32d3984d9e184a2081033ec 100644 (file)
@@ -239,7 +239,7 @@ static FILE *debug_fp = NULL;
 static HANDLE debug_hdl = INVALID_HANDLE_VALUE;
 static int debug_got_console = 0;
 
-void dputs(char *buf)
+void dputs(const char *buf)
 {
     DWORD dw;
 
index 039701cf0bd9b9aab05d0e0f89c9f7af3622f6e2..5e05cfc29978366f44918b9b7518c8e4b65ef3a0 100644 (file)
@@ -50,7 +50,7 @@ struct SockAddrStep_tag {
 struct Socket_tag {
     const struct socket_function_table *fn;
     /* the above variable absolutely *must* be the first in this structure */
-    char *error;
+    const char *error;
     SOCKET s;
     Plug plug;
     bufchain output_data;
@@ -356,7 +356,7 @@ static int errstring_compare(void *av, void *bv)
 
 static tree234 *errstrings = NULL;
 
-char *winsock_error_string(int error)
+const char *winsock_error_string(int error)
 {
     const char prefix[] = "Network error: ";
     struct errstring *es;
@@ -1162,8 +1162,8 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
     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)
 {
     static const struct socket_function_table fn_table = {
        sk_tcp_plug,
index 753cf141569a0899f37db1ccd68db899a4562309..e67a55af2f238287968d2a27fd07e7fd2c7c2f6f 100644 (file)
@@ -27,7 +27,7 @@ static char *cmdline_keyfile = NULL;
 /*
  * Print a modal (Really Bad) message box and perform a fatal exit.
  */
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
 {
     va_list ap;
     char *stuff;
@@ -44,7 +44,7 @@ void modalfatalbox(char *fmt, ...)
 /*
  * Print a non-fatal message box and do not exit.
  */
-void nonfatal(char *fmt, ...)
+void nonfatal(const char *fmt, ...)
 {
     va_list ap;
     char *stuff;
@@ -1372,7 +1372,7 @@ static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
       case WM_HELP:
         {
             int id = ((LPHELPINFO)lParam)->iCtrlId;
-            char *topic = NULL;
+            const char *topic = NULL;
             switch (id) {
               case IDC_GENERATING:
               case IDC_PROGRESS:
index 70f8309eb174307b7995063cb7012ded6ff2bb15..73de99dd3fa1e8fa63d57470f21b2703f74260bc 100644 (file)
@@ -70,7 +70,7 @@ static int initial_menuitems_count;
 /*
  * Print a modal (Really Bad) message box and perform a fatal exit.
  */
-void modalfatalbox(char *fmt, ...)
+void modalfatalbox(const char *fmt, ...)
 {
     va_list ap;
     char *buf;
@@ -594,7 +594,7 @@ static int CALLBACK KeyListProc(HWND hwnd, UINT msg,
       case WM_HELP:
         {
             int id = ((LPHELPINFO)lParam)->iCtrlId;
-            char *topic = NULL;
+            const char *topic = NULL;
             switch (id) {
               case 100: topic = WINHELP_CTX_pageant_keylist; 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]
  */
-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,
                     args, NULL, show) <= (HINSTANCE) 32) {
@@ -1023,7 +1023,7 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
 {
     WNDCLASS wndclass;
     MSG msg;
-    char *command = NULL;
+    const char *command = NULL;
     int added_keys = 0;
     int argc, i;
     char **argv, **argstart;
index f154ebc9a0dd6febee73adb38d90b22a93a3c5e4..43f53bb0426829891504e07b911b9b870b660fd0 100644 (file)
@@ -21,7 +21,7 @@ struct agent_callback {
     int len;
 };
 
-void fatalbox(char *p, ...)
+void fatalbox(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "FATAL ERROR: ");
@@ -35,7 +35,7 @@ void fatalbox(char *p, ...)
     }
     cleanup_exit(1);
 }
-void modalfatalbox(char *p, ...)
+void modalfatalbox(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "FATAL ERROR: ");
@@ -49,7 +49,7 @@ void modalfatalbox(char *p, ...)
     }
     cleanup_exit(1);
 }
-void nonfatal(char *p, ...)
+void nonfatal(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "ERROR: ");
@@ -58,7 +58,7 @@ void nonfatal(char *p, ...)
     va_end(ap);
     fputc('\n', stderr);
 }
-void connection_fatal(void *frontend, char *p, ...)
+void connection_fatal(void *frontend, const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "FATAL ERROR: ");
@@ -72,7 +72,7 @@ void connection_fatal(void *frontend, char *p, ...)
     }
     cleanup_exit(1);
 }
-void cmdline_error(char *p, ...)
+void cmdline_error(const char *p, ...)
 {
     va_list ap;
     fprintf(stderr, "plink: ");
@@ -145,7 +145,7 @@ int from_backend_eof(void *frontend_handle)
     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;
     ret = cmdline_get_passwd_input(p, in, inlen);
index aa14b91ae9898e8ffc2a81c789b49144ab5e6920..949546000f0c833fb80ed3e7131d7dc1b1675d6c 100644 (file)
@@ -16,7 +16,7 @@
 Socket make_handle_socket(HANDLE send_H, HANDLE recv_H, Plug plug,
                           int overlapped);
 
-Socket platform_new_connection(SockAddr addr, char *hostname,
+Socket platform_new_connection(SockAddr addr, const char *hostname,
                               int port, int privport,
                               int oobinline, int nodelay, int keepalive,
                               Plug plug, Conf *conf)
index 086d3e5cd4fcb2b3e7fbe8b767ac36748b0afd38..3f1326dba16badaabc4a4ca503b0d027f97dfa69 100644 (file)
@@ -199,7 +199,7 @@ static const char *serial_configure(Serial serial, HANDLE serport, Conf *conf)
  * freed by the caller.
  */
 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)
 {
     Serial serial;
@@ -302,7 +302,7 @@ static void serial_reconfig(void *handle, Conf *conf)
 /*
  * 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;
 
index d061b514843a56d66bbd8d6f4ed91e945b7aa89a..fa052eebffc5c5b41b201c1065c5317eafbe2c9c 100644 (file)
@@ -11,7 +11,7 @@
 
 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;
     ret = cmdline_get_passwd_input(p, in, inlen);
@@ -87,7 +87,7 @@ struct RFile {
     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,
                           long *perms)
 {
@@ -141,7 +141,7 @@ struct WFile {
     HANDLE h;
 };
 
-WFile *open_new_file(char *name, long perms)
+WFile *open_new_file(const char *name, long perms)
 {
     HANDLE h;
     WFile *ret;
@@ -157,7 +157,7 @@ WFile *open_new_file(char *name, long perms)
     return ret;
 }
 
-WFile *open_existing_wfile(char *name, uint64 *size)
+WFile *open_existing_wfile(const char *name, uint64 *size)
 {
     HANDLE h;
     WFile *ret;
@@ -239,7 +239,7 @@ uint64 get_file_posn(WFile *f)
     return ret;
 }
 
-int file_type(char *name)
+int file_type(const char *name)
 {
     DWORD attr;
     attr = GetFileAttributes(name);
@@ -257,7 +257,7 @@ struct DirHandle {
     char *name;
 };
 
-DirHandle *open_directory(char *name)
+DirHandle *open_directory(const char *name)
 {
     HANDLE h;
     WIN32_FIND_DATA fdat;
@@ -316,7 +316,7 @@ void close_directory(DirHandle *dir)
     sfree(dir);
 }
 
-int test_wildcard(char *name, int cmdline)
+int test_wildcard(const char *name, int cmdline)
 {
     HANDLE fh;
     WIN32_FIND_DATA fdat;
@@ -364,7 +364,7 @@ static char *stripslashes(char *str, int local)
     return str;
 }
 
-WildcardMatcher *begin_wildcard_matching(char *name)
+WildcardMatcher *begin_wildcard_matching(const char *name)
 {
     HANDLE h;
     WIN32_FIND_DATA fdat;
@@ -424,7 +424,7 @@ void finish_wildcard_matching(WildcardMatcher *dir)
     sfree(dir);
 }
 
-int vet_filename(char *name)
+int vet_filename(const char *name)
 {
     if (strchr(name, '/') || strchr(name, '\\') || strchr(name, ':'))
        return FALSE;
@@ -435,12 +435,12 @@ int vet_filename(char *name)
     return TRUE;
 }
 
-int create_directory(char *name)
+int create_directory(const char *name)
 {
     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);
 }
@@ -691,7 +691,7 @@ static DWORD WINAPI command_read_thread(void *param)
     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;
     struct command_read_ctx actx, *ctx = &actx;
index 14728a815a86c46d9f1881dfc6c76d4381d46248..c1888f9eda93ba6663b6368ef9a36d348f8f62e7 100644 (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,
-            char *mbstr, int mblen, char *defchr, int *defused,
+            char *mbstr, int mblen, const char *defchr, int *defused,
             struct unicode_data *ucsdata)
 {
     char *p;
index f68405bcdf5eb4ff6b06726cd4358869b591e935..c81e7fe0c040744f5e0e5e950f6cab5685d3f33b 100644 (file)
@@ -94,7 +94,7 @@ void filereq_free(filereq *state)
 /* Callback function to launch context help. */
 static VOID CALLBACK message_box_help_callback(LPHELPINFO lpHelpInfo)
 {
-    char *context = NULL;
+    const char *context = NULL;
 #define CHECK_CTX(name) \
     do { \
        if (lpHelpInfo->dwContextId == WINHELP_CTXID_ ## name) \
index 4a6d82704b7cdbccbed5a1dfcf964aaa2dda9cbd..e42edf7549dfebc937f1f3675bd6035f384c910f 100644 (file)
--- a/x11fwd.c
+++ b/x11fwd.c
@@ -357,10 +357,10 @@ void x11_free_display(struct X11Display *disp)
 
 #define XDM_MAXSKEW 20*60      /* 20 minute clock skew should be OK */
 
-static char *x11_verify(unsigned long peer_ip, int peer_port,
-                       tree234 *authtree, char *proto,
-                       unsigned char *data, int dlen,
-                        struct X11FakeAuth **auth_ret)
+static const char *x11_verify(unsigned long peer_ip, int peer_port,
+                              tree234 *authtree, char *proto,
+                              unsigned char *data, int dlen,
+                              struct X11FakeAuth **auth_ret)
 {
     struct X11FakeAuth match_dummy;    /* for passing to find234 */
     struct X11FakeAuth *auth;