Index: head/usr.bin/posixshmcontrol/posixshmcontrol.1 =================================================================== --- head/usr.bin/posixshmcontrol/posixshmcontrol.1 +++ head/usr.bin/posixshmcontrol/posixshmcontrol.1 @@ -120,7 +120,7 @@ To show content of the shared memory segment with the path .Pa /1 , use the command -.Dl "posixshmcontrol dump /q | hexdump -C" +.Dl "posixshmcontrol dump /1 | hexdump -C" .It To create a segment with the path .Pa /2 Index: head/usr.bin/posixshmcontrol/posixshmcontrol.c =================================================================== --- head/usr.bin/posixshmcontrol/posixshmcontrol.c +++ head/usr.bin/posixshmcontrol/posixshmcontrol.c @@ -147,9 +147,14 @@ return (2); } } - argc -= optind; argv += optind; + + if (argc == 0) { + usage(); + return (2); + } + ret = 0; for (i = 0; i < argc; i++) { ret1 = create_one_shm(argv[i], mode, idx); @@ -179,6 +184,11 @@ { int i, ret, ret1; + if (argc == 1) { + usage(); + return (2); + } + ret = 0; for (i = 1; i < argc; i++) { ret1 = delete_one_shm(argv[i]); @@ -347,6 +357,11 @@ { int i, ret, ret1; + if (argc == 1) { + usage(); + return (2); + } + ret = 0; for (i = 1; i < argc; i++) { ret1 = read_one_shm(argv[i]); @@ -433,6 +448,11 @@ argc -= optind; argv += optind; + if (argc == 0) { + usage(); + return (2); + } + ret = 0; for (i = 0; i < argc; i++) { ret1 = stat_one_shm(argv[i], hsize, uname); @@ -473,16 +493,21 @@ switch (c) { case 's': if (expand_number(optarg, &newsize) == -1) - err(1, "size:"); + err(1, "size"); break; case '?': default: return (2); } } - argc -= optind; argv += optind; + + if (argc == 0) { + usage(); + return (2); + } + ret = 0; for (i = 0; i < argc; i++) { ret1 = truncate_one_shm(argv[i], newsize);