From 4bbe0b48dae4b60bbec53abb82206f0f71d28f46 Mon Sep 17 00:00:00 2001 From: AlexanderFuh <74897172+AlexanderFuh@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:06:36 +0100 Subject: [PATCH] Update Integer32.cs ToErrorCode() should not throw exceptions as the method is invoked by error message display and ToString() methods. Also, as the ErrorCode field of a SNMP packet is read/parsed by this class, a device migth brake/create a DOS by simply sending an error code unknown to the lib. We'd loose compatibility and introduce issues without any need or gain. --- SharpSnmpLib/Integer32.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/SharpSnmpLib/Integer32.cs b/SharpSnmpLib/Integer32.cs index df468b83..610eb738 100644 --- a/SharpSnmpLib/Integer32.cs +++ b/SharpSnmpLib/Integer32.cs @@ -132,11 +132,6 @@ public int ToInt32() /// public ErrorCode ToErrorCode() { - if (_int > 19 || _int < 0) - { - throw new InvalidCastException(); - } - return (ErrorCode)_int; }