]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check for duplicate arguments to tor-gencert
authorNick Mathewson <nickm@torproject.org>
Thu, 21 Aug 2014 15:09:40 +0000 (11:09 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 21 Aug 2014 15:22:42 +0000 (11:22 -0400)
Found by coverity, which noticed that if you said
  tor-gencert -i identity1 -i identity2
we would leak "identity1".

[CID 119820111982021198203]

changes/check_dup_args_gencert [new file with mode: 0644]
src/tools/tor-gencert.c

diff --git a/changes/check_dup_args_gencert b/changes/check_dup_args_gencert
new file mode 100644 (file)
index 0000000..d0925df
--- /dev/null
@@ -0,0 +1,3 @@
+  o Minor features:
+    - In tor-gencert, report an error if the user provides the same
+      argument more than once.
index e799df5cad7597d3ad305d31d9ecc75337e9b02a..fae26ef9568defd4911b98775570cd5df6be1054 100644 (file)
@@ -134,18 +134,30 @@ parse_commandline(int argc, char **argv)
         fprintf(stderr, "No argument to -i\n");
         return 1;
       }
+      if (identity_key_file) {
+        fprintf(stderr, "Duplicate values for -i\n");
+        return -1;
+      }
       identity_key_file = tor_strdup(argv[++i]);
     } else if (!strcmp(argv[i], "-s")) {
       if (i+1>=argc) {
         fprintf(stderr, "No argument to -s\n");
         return 1;
       }
+      if (signing_key_file) {
+        fprintf(stderr, "Duplicate values for -s\n");
+        return -1;
+      }
       signing_key_file = tor_strdup(argv[++i]);
     } else if (!strcmp(argv[i], "-c")) {
       if (i+1>=argc) {
         fprintf(stderr, "No argument to -c\n");
         return 1;
       }
+      if (certificate_file) {
+        fprintf(stderr, "Duplicate values for -c\n");
+        return -1;
+      }
       certificate_file = tor_strdup(argv[++i]);
     } else if (!strcmp(argv[i], "-m")) {
       if (i+1>=argc) {