Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use Process.GetCurrentProcess() to get calling executable [DNET293] #304

Closed
firebird-automations opened this issue Feb 5, 2010 · 7 comments

Comments

@firebird-automations
Copy link

Submitted by: Valeriy K. (darkside)

In FbConnectionInternal.cs at line 548 DO NOT use "Process.GetCurrentProcess().MainModule.FileName" to determine calling executable. Instead of this please use "Assembly.GetEntryAssembly().Location" because call to Process.GetCurrentProcess() demands application to increase it privileges to "Debug privileges" (that we don't need at all).

By calling "Assembly.GetEntryAssembly().Location" we will get the same process string as call to "Process.GetCurrentProcess().MainModule.FileName" but without requesting debug privileges.

Commits: d3bdf16

@firebird-automations
Copy link
Author

Modified by: Valeriy K. (darkside)

priority: Blocker [ 1 ] => Critical [ 2 ]

@firebird-automations
Copy link
Author

Modified by: Valeriy K. (darkside)

description: In FbConnectionInternal.cs at line 548 DO NOT use "Process.GetCurrentProcess().MainModule.FileName" to determine calling executable. Instead of this please use "Assembly.GetEntryAssembly().Location" because call to Process.GetCurrentProcess() demands application to increase they privileges to "Debug privileges" (that we don't need at all).

By calling "Assembly.GetEntryAssembly().Location" we will get the same process string as call to "Process.GetCurrentProcess().MainModule.FileName" but without requesting debug privileges.

=>

In FbConnectionInternal.cs at line 548 DO NOT use "Process.GetCurrentProcess().MainModule.FileName" to determine calling executable. Instead of this please use "Assembly.GetEntryAssembly().Location" because call to Process.GetCurrentProcess() demands application to increase it privileges to "Debug privileges" (that we don't need at all).

By calling "Assembly.GetEntryAssembly().Location" we will get the same process string as call to "Process.GetCurrentProcess().MainModule.FileName" but without requesting debug privileges.

@firebird-automations
Copy link
Author

Commented by: @cincuranet

That's only partially true. The GetEntryAssembly method doesn't work for unmanaged code, hence if you load the assembly from i.e. VS, you'll be able to send the path to process.

@firebird-automations
Copy link
Author

Commented by: Valeriy K. (darkside)

Hm... I thought that .NET Firebird Client library is designed to use with managed code only. Anyway, it possible to do a workaround:

String execProc = Assembly.GetEntryAssembly() == null ? Process.GetCurrentProcess().MainModule.FileName : Assembly.GetEntryAssembly().Location;

What do you say?

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Yes, this looks good enough.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5.3 [ 10380 ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

Fix Version: 2.6 [ 10371 ]

Fix Version: 2.5.3 [ 10380 ] =>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants