projects
/
u
/
mdw
/
putty
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updates to svn:ignore: ignore libversion.a in the top-level directory
[u/mdw/putty]
/
cmdgen.c
diff --git
a/cmdgen.c
b/cmdgen.c
index
763d05e
..
9911db1
100644
(file)
--- a/
cmdgen.c
+++ b/
cmdgen.c
@@
-119,7
+119,7
@@
void sk_cleanup(void)
void showversion(void)
{
char *verstr = dupstr(ver);
void showversion(void)
{
char *verstr = dupstr(ver);
- verstr[0] = tolower(verstr[0]);
+ verstr[0] = tolower(
(unsigned char)
verstr[0]);
printf("PuTTYgen %s\n", verstr);
sfree(verstr);
}
printf("PuTTYgen %s\n", verstr);
sfree(verstr);
}
@@
-233,7
+233,7
@@
static int move(char *from, char *to)
return TRUE;
}
return TRUE;
}
-static char *blobfp(char *alg, int bits, char *blob, int bloblen)
+static char *blobfp(char *alg, int bits,
unsigned
char *blob, int bloblen)
{
char buffer[128];
unsigned char digest[16];
{
char buffer[128];
unsigned char digest[16];
@@
-270,7
+270,8
@@
int main(int argc, char **argv)
int sshver = 0;
struct ssh2_userkey *ssh2key = NULL;
struct RSAKey *ssh1key = NULL;
int sshver = 0;
struct ssh2_userkey *ssh2key = NULL;
struct RSAKey *ssh1key = NULL;
- char *ssh2blob = NULL, *ssh2alg = NULL;
+ unsigned char *ssh2blob = NULL;
+ char *ssh2alg = NULL;
const struct ssh_signkey *ssh2algf = NULL;
int ssh2bloblen;
char *passphrase = NULL;
const struct ssh_signkey *ssh2algf = NULL;
int ssh2bloblen;
char *passphrase = NULL;
@@
-315,25
+316,47
@@
int main(int argc, char **argv)
*p++ = '\0';
val = p;
} else
*p++ = '\0';
val = p;
} else
- val = NULL;
+ val = NULL;
+
if (!strcmp(opt, "-help")) {
if (!strcmp(opt, "-help")) {
- help();
- nogo = TRUE;
+ if (val) {
+ errs = TRUE;
+ fprintf(stderr, "puttygen: option `-%s'"
+ " expects no argument\n", opt);
+ } else {
+ help();
+ nogo = TRUE;
+ }
} else if (!strcmp(opt, "-version")) {
} else if (!strcmp(opt, "-version")) {
- showversion();
- nogo = TRUE;
+ if (val) {
+ errs = TRUE;
+ fprintf(stderr, "puttygen: option `-%s'"
+ " expects no argument\n", opt);
+ } else {
+ showversion();
+ nogo = TRUE;
+ }
} else if (!strcmp(opt, "-pgpfp")) {
} else if (!strcmp(opt, "-pgpfp")) {
- /* support "-pgpfp" for consistency with others */
- pgp_fingerprints();
- nogo = TRUE;
+ if (val) {
+ errs = TRUE;
+ fprintf(stderr, "puttygen: option `-%s'"
+ " expects no argument\n", opt);
+ } else {
+ /* support --pgpfp for consistency */
+ pgp_fingerprints();
+ nogo = TRUE;
+ }
}
/*
}
/*
- * A sample option requiring an argument:
+ * For long options requiring an argument, add
+ * code along the lines of
*
* else if (!strcmp(opt, "-output")) {
*
* else if (!strcmp(opt, "-output")) {
- * if (!val)
- * errs = TRUE, error(err_optnoarg, opt);
- * else
+ * if (!val) {
+ * errs = TRUE;
+ * fprintf(stderr, "puttygen: option `-%s'"
+ * " expects an argument\n", opt);
+ * } else
* ofile = val;
* }
*/
* ofile = val;
* }
*/
@@
-639,6
+662,11
@@
int main(int argc, char **argv)
random_ref();
entropy = get_random_data(bits / 8);
random_ref();
entropy = get_random_data(bits / 8);
+ if (!entropy) {
+ fprintf(stderr, "puttygen: failed to collect entropy, "
+ "could not generate key\n");
+ return 1;
+ }
random_add_heavynoise(entropy, bits / 8);
memset(entropy, 0, bits/8);
sfree(entropy);
random_add_heavynoise(entropy, bits / 8);
memset(entropy, 0, bits/8);
sfree(entropy);
@@
-715,12
+743,12
@@
int main(int argc, char **argv)
ssh1key = snew(struct RSAKey);
if (!load_encrypted) {
void *vblob;
ssh1key = snew(struct RSAKey);
if (!load_encrypted) {
void *vblob;
- char *blob;
+
unsigned
char *blob;
int n, l, bloblen;
ret = rsakey_pubblob(&infilename, &vblob, &bloblen,
&origcomment, &error);
int n, l, bloblen;
ret = rsakey_pubblob(&infilename, &vblob, &bloblen,
&origcomment, &error);
- blob = (char *)vblob;
+ blob = (
unsigned
char *)vblob;
n = 4; /* skip modulus bits */
n = 4; /* skip modulus bits */
@@
-892,7
+920,7
@@
int main(int argc, char **argv)
assert(ssh1key);
if (outfile)
assert(ssh1key);
if (outfile)
- fp = f_open(outfilename, "w");
+ fp = f_open(outfilename, "w"
, FALSE
);
else
fp = stdout;
dec1 = bignum_decimal(ssh1key->exponent);
else
fp = stdout;
dec1 = bignum_decimal(ssh1key->exponent);
@@
-950,7
+978,7
@@
int main(int argc, char **argv)
*p++ = '\0';
if (outfile)
*p++ = '\0';
if (outfile)
- fp = f_open(outfilename, "w");
+ fp = f_open(outfilename, "w"
, FALSE
);
else
fp = stdout;
fprintf(fp, "%s\n", buffer);
else
fp = stdout;
fprintf(fp, "%s\n", buffer);
@@
-980,7
+1008,7
@@
int main(int argc, char **argv)
}
if (outfile)
}
if (outfile)
- fp = f_open(outfilename, "w");
+ fp = f_open(outfilename, "w"
, FALSE
);
else
fp = stdout;
fprintf(fp, "%s\n", fingerprint);
else
fp = stdout;
fprintf(fp, "%s\n", fingerprint);