channel_mgmt: Handle uncaught exception in syncNetworkChannelConfig

convertToPrivLimitIndex() throws std::invalid_argument exception when
the argument is not a valid privilege string, which is not handled
in syncNetworkChannelConfig(). This patch fixes it by skipping the
interface when it throws to prevent the ipmi-host service from
crashing.

Tested:
phosphor-ipmi-host is not crashed after manually setting the
MaxPrivilege of an interface to an invalid empty string in
phosphor-networkd.

Change-Id: Ib0361495f1751997fd8fb7e19d9f133888f426d0
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
diff --git a/user_channel/channel_mgmt.cpp b/user_channel/channel_mgmt.cpp
index 7d3cf95..9ddd5ad 100644
--- a/user_channel/channel_mgmt.cpp
+++ b/user_channel/channel_mgmt.cpp
@@ -1373,6 +1373,7 @@
         if (getChannelSessionSupport(chNum) != EChannelSessSupported::none)
         {
             std::string intfPrivStr;
+            uint8_t intfPriv = 0;
             try
             {
                 std::string networkIntfObj =
@@ -1389,6 +1390,8 @@
                     continue;
                 }
                 intfPrivStr = std::get<std::string>(variant);
+                intfPriv =
+                    static_cast<uint8_t>(convertToPrivLimitIndex(intfPrivStr));
             }
             catch (const std::bad_variant_access& e)
             {
@@ -1402,9 +1405,12 @@
                     "exception: Network interface does not exist");
                 continue;
             }
+            catch (const std::invalid_argument& e)
+            {
+                log<level::DEBUG>("exception: Invalid privilege");
+                continue;
+            }
 
-            uint8_t intfPriv =
-                static_cast<uint8_t>(convertToPrivLimitIndex(intfPrivStr));
             if (channelData[chNum].chAccess.chNonVolatileData.privLimit !=
                 intfPriv)
             {