icsharpcode / SharpDevelop

#develop (short for SharpDevelop) is a free IDE for .NET programming languages.
2.08k stars 771 forks source link

Possible bug in source code (CWE-571) #789

Open AppChecker opened 7 years ago

AppChecker commented 7 years ago

Hello!

We've checked your code with AppChecker static analyzer and found possible bug:

https://github.com/icsharpcode/SharpDevelop/blob/ba372efbff09121ce07651c17ed5fa6db27d7c5c/samples/ComponentInspector/ComponentInspector.Core/Src/Util/ReflectionHelper.cs#L76

        internal static bool IsMemberEqual(MemberInfo m1,
                                           MemberInfo m2)
        {
            if (!m1.GetType().Equals(m1.GetType()))
                return false;
            if (!m1.DeclaringType.Equals(m2.DeclaringType))
                return false;
            if (!m1.Name.Equals(m2.Name))
                return false;
....
        }

m1.GetType() is compared with itself. We think it should be m2.GetType() instead

Possible defect was found by Echelon Team with AppChecker static analyzer