]> granicus.if.org Git - icinga2/commitdiff
Fix crash when specifying invalid argument for --autocomplete
authorGunnar Beutner <gunnar@beutner.name>
Tue, 3 Mar 2015 08:23:38 +0000 (09:23 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 3 Mar 2015 08:24:10 +0000 (09:24 +0100)
Coverity Bug ID: 1167734

icinga-app/icinga.cpp

index 3ca2ce933f0c754faf01ecb768c52c986b4e60a7..0cb447a7baef5125a5ea78fb71d75b13a9b1198a 100644 (file)
@@ -96,7 +96,15 @@ int Main(void)
 
        if (argc >= 4 && strcmp(argv[1], "--autocomplete") == 0) {
                autocomplete = true;
-               autoindex = Convert::ToLong(argv[2]);
+
+               try {
+                       autoindex = Convert::ToLong(argv[2]);
+               } catch (const std::invalid_argument& ex) {
+                       Log(LogCritical, "icinga-app")
+                           << "Invalid index for --autocomplete: " << argv[2];
+                       return EXIT_FAILURE;
+               }
+
                argc -= 3;
                argv += 3;
        }