]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - cmdgen.c
Document '-restrict-acl' vs subprocesses.
[PuTTY.git] / cmdgen.c
index 4e83336c9f496e6c6dc6dfee80a457c52c5b5f01..d6c1f72115ac3080b17e7750aa1ee15350637e08 100644 (file)
--- a/cmdgen.c
+++ b/cmdgen.c
@@ -19,7 +19,7 @@
 #ifdef TEST_CMDGEN
 /*
  * This section overrides some definitions below for test purposes.
- * When compiled with -DTEST_CMDGEN:
+ * When compiled with -DTEST_CMDGEN (as cgtest.c will do):
  * 
  *  - Calls to get_random_data() are replaced with the diagnostic
  *    function below (I #define the name so that I can still link
@@ -52,8 +52,7 @@ int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
     int ret = 1;
     for (i = 0; i < p->n_prompts; i++) {
        if (promptsgot < nprompts) {
-           assert(strlen(prompts[promptsgot]) < p->prompts[i]->result_len);
-           strcpy(p->prompts[i]->result, prompts[promptsgot++]);
+           p->prompts[i]->result = dupstr(prompts[promptsgot++]);
        } else {
            promptsgot++;           /* track number of requests anyway */
            ret = 0;
@@ -130,7 +129,9 @@ void sk_cleanup(void)
 
 void showversion(void)
 {
-    printf("puttygen: %s\n", ver);
+    char *buildinfo_text = buildinfo("\n");
+    printf("puttygen: %s\n%s", ver, buildinfo_text);
+    sfree(buildinfo_text);
 }
 
 void usage(int standalone)
@@ -224,6 +225,8 @@ static char *readpassphrase(const char *filename)
     return line;
 }
 
+#define DEFAULT_RSADSA_BITS 2048
+
 int main(int argc, char **argv)
 {
     char *infile = NULL;
@@ -501,7 +504,7 @@ int main(int argc, char **argv)
             bits = 256;
             break;
           default:
-            bits = 2048;
+            bits = DEFAULT_RSADSA_BITS;
             break;
         }
     }
@@ -516,6 +519,19 @@ int main(int argc, char **argv)
         errs = TRUE;
     }
 
+    if (keytype == RSA2 || keytype == RSA1 || keytype == DSA) {
+        if (bits < 256) {
+            fprintf(stderr, "puttygen: cannot generate %s keys shorter than"
+                    " 256 bits\n", (keytype == DSA ? "DSA" : "RSA"));
+            errs = TRUE;
+        } else if (bits < DEFAULT_RSADSA_BITS) {
+            fprintf(stderr, "puttygen: warning: %s keys shorter than"
+                    " %d bits are probably not secure\n",
+                    (keytype == DSA ? "DSA" : "RSA"), DEFAULT_RSADSA_BITS);
+            /* but this is just a warning, so proceed anyway */
+        }
+    }
+
     if (errs)
        return 1;
 
@@ -1193,7 +1209,7 @@ char *cleanup_fp(char *s)
     s += strspn(s, " \n\t");
     s += strcspn(s, " \n\t");
 
-    return dupprintf("%.*s", s - p, p);
+    return dupprintf("%.*s", (int)(s - p), p);
 }
 
 char *get_fp(char *filename)