Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/rump_allserver Guard against supplying the same para...



details:   https://anonhg.NetBSD.org/src/rev/4aae5b52dacc
branches:  trunk
changeset: 759735:4aae5b52dacc
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Dec 15 19:07:43 2010 +0000

description:
Guard against supplying the same parameter multiple times in one -d argument.

diffstat:

 usr.bin/rump_allserver/rump_allserver.c |  19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diffs (46 lines):

diff -r 12880c62c10e -r 4aae5b52dacc usr.bin/rump_allserver/rump_allserver.c
--- a/usr.bin/rump_allserver/rump_allserver.c   Wed Dec 15 18:42:59 2010 +0000
+++ b/usr.bin/rump_allserver/rump_allserver.c   Wed Dec 15 19:07:43 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_allserver.c,v 1.10 2010/12/15 09:40:21 wiz Exp $  */
+/*     $NetBSD: rump_allserver.c,v 1.11 2010/12/15 19:07:43 pooka Exp $        */
 
 /*-
  * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: rump_allserver.c,v 1.10 2010/12/15 09:40:21 wiz Exp $");
+__RCSID("$NetBSD: rump_allserver.c,v 1.11 2010/12/15 19:07:43 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -119,12 +119,27 @@
                                switch (getsubopt(&options,
                                    __UNCONST(disktokens), &value)) {
                                case DKEY:
+                                       if (key != NULL) {
+                                               fprintf(stderr,
+                                                   "key already given\n");
+                                               usage();
+                                       }
                                        key = value;
                                        break;
                                case DFILE:
+                                       if (hostpath != NULL) {
+                                               fprintf(stderr,
+                                                   "hostpath already given\n");
+                                               usage();
+                                       }
                                        hostpath = value;
                                        break;
                                case DSIZE:
+                                       if (flen != 0) {
+                                               fprintf(stderr,
+                                                   "size already given\n");
+                                               usage();
+                                       }
                                        /* XXX: off_t max? */
                                        flen = strsuftoll("-d size", value,
                                            0, LLONG_MAX);



Home | Main Index | Thread Index | Old Index