summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2018-01-14 00:11:08 -0500
committerAllan McRae <allan@archlinux.org>2018-01-19 12:05:39 +1000
commitd911438352ebec5a887dac02ceb0bb99f54b34fc (patch)
tree817d38150503c51cbce321a2b1c30283327d8fa5
parent19dabcc19a476735c4273e7ba4a0a7437d83078f (diff)
downloadpacman-d911438352ebec5a887dac02ceb0bb99f54b34fc.tar.xz
vercmp: fail when the wrong number of arguments are provided
Fixes FS#49093 Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--src/util/vercmp.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/util/vercmp.c b/src/util/vercmp.c
index 0b5d4508..1b2f979e 100644
--- a/src/util/vercmp.c
+++ b/src/util/vercmp.c
@@ -40,8 +40,6 @@ static void usage(void)
int main(int argc, char *argv[])
{
- const char *s1 = "";
- const char *s2 = "";
int ret;
if(argc == 1) {
@@ -53,14 +51,13 @@ int main(int argc, char *argv[])
usage();
return 0;
}
- if(argc > 2) {
- s2 = argv[2];
- }
- if(argc > 1) {
- s1 = argv[1];
+ if(argc != 3) {
+ fprintf(stderr, "error: %d argument(s) specified\n\n"
+ "Usage: vercmp <ver1> <ver2>\n", argc - 1);
+ return EXIT_FAILURE;
}
- ret = alpm_pkg_vercmp(s1, s2);
+ ret = alpm_pkg_vercmp(argv[1], argv[2]);
printf("%d\n", ret);
return EXIT_SUCCESS;
}