From: Gunnar Beutner Date: Tue, 3 Mar 2015 08:23:38 +0000 (+0100) Subject: Fix crash when specifying invalid argument for --autocomplete X-Git-Tag: v2.3.0~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ba6b92a929a2f798838f8809079126db4e85c941;p=icinga2 Fix crash when specifying invalid argument for --autocomplete Coverity Bug ID: 1167734 --- diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 3ca2ce933..0cb447a7b 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -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; }