1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-10 07:43:48 -05:00

Giant const-correctness patch of doom!

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

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

13
ssh.h
View File

@ -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);