summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2012-01-20 12:04:19 -0800
committerRoland McGrath <roland@hack.frob.com>2012-01-20 12:04:19 -0800
commit9bffd3604c25bb688fe3a1c19654891d4df47272 (patch)
tree4014981429494baecc4bc0f9ce1cdaeb13c0dea1
parent6e063d99a12beedde3ce1d4dc75c428d0ee7600e (diff)
ar: Don't crash when given files but no command.
-rw-r--r--src/ChangeLog2
-rw-r--r--src/ar.c7
2 files changed, 9 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 46c277ce..98c32421 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,7 @@
2012-01-20 Roland McGrath <roland@hack.frob.com>
+ * ar.c (main): Handle oper_none as usage error.
+
* arlib-argp.c (options, parse_opt): Grok -U as inverse of -D.
* ranlib.c (argp): Use arlib_argp_children.
diff --git a/src/ar.c b/src/ar.c
index 72b0237f..147d9f2b 100644
--- a/src/ar.c
+++ b/src/ar.c
@@ -252,6 +252,13 @@ MEMBER parameter required for 'a', 'b', and 'i' modifiers"));
int status;
switch (operation)
{
+ case oper_none:
+ error (0, 0, gettext ("command option required"));
+ argp_help (&argp, stderr, ARGP_HELP_STD_ERR,
+ program_invocation_short_name);
+ status = 1;
+ break;
+
case oper_list:
case oper_print:
status = do_oper_extract (operation, arfname, argv, argc, -1);