对于以下部署的代码是否可以到达或“悬挂”into...even,正在进行安全讨论,尽管它是在发布模式下构建的。
有什么想法?
编辑:
我确实在DotPeek中“看到”了--即使是在发布构建之后。
代码看起来像:
using System;
using System.ServiceProcess;
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
#if DEBUG
var myservice = new StpListener();
myservice.OnDebug();
//KEEP the service alive
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
#else
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new StpListener()
};
ServiceBase.Run(ServicesToRun);
#endif
}
} 发布于 2017-01-26 12:46:56
发布于 2017-01-26 12:47:13
这是编译时特性。一旦编译器完成了它的工作,您将要么在#if和#else之间得到代码,要么在#else和#endif之间得到代码。
您将永远不会(只要将这些项放在其中)生成包含这两组代码的二进制代码。
发布于 2017-01-26 12:46:24
假设您正在使用Roslyn编译器(尽管对所有兼容C#的编译器来说都是如此),#if DEBUG代码甚至不会编译到IL中,因此绝对不能被访问。
但是,如果您使用Conditional("DEBUG"),代码会将其转化为IL,并且只会删除对它的调用,因此可以说这可能是一个安全缺陷。
https://stackoverflow.com/questions/41873726
复制相似问题