1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nataly_w [17]
3 years ago
13

Consider the following general code for allowing access to a resource:

Computers and Technology
1 answer:
Margaret [11]3 years ago
6 0

Answer:

a) The code allows access even when  IsAccessAllowed(...) method fails.

b) Either use If

(dwRet = ACCESS_ALLOWED)

or use

if (dwRet == NO_ERROR)

to avoid flaw

Explanation:

Lets first see what the code chunk does:

DWORD dwRet = IsAccessAllowed(...);

if (dwRet == ERROR_ACCESS_DENIED) {

// Security check failed.

// Inform user that access is denied.

} else {

// Security check OK.

}

In the given code, DWORD is basically a data type for double word type integers and this is defined in windows.h

So there is DWORD type variable dwRet that is assigned a method calls.

The method is IsAccessAllowed() which checks if the access is allowed to user.

if (dwRet == ERROR_ACCESS_DENIED) condition basically checks if the value of DWORD type variable dwRet is equal to ERROR_ACCESS_DENIED

If this condition evaluates to true then the security checks fails and user is informed via some message or action that the access is denied.  But when the if condition evaluates to false then the else part executes which allows access.

So basically this chunk of code checks if the error ERROR_ACCESS_DENIED is returned.

Now the flaw in this program is what if the method IsAccessAllowed() by any reason. The reasons can be system failure or the memory failure. In memory failure case for example, the system returns out of memory error. So this means that the error is not  ERROR_ACCESS_DENIED. Instead it is out of memory error. So in such a case the user is allowed access as the if condition evaluates to false and else part executes. So if any other error is produced due to some reason like mentioned above, then user has unrestricted access.

This shows that the doe should not check for the failure or rely on checking ERROR_ACCESS_DENIED to allow access but instead it should check for success. Code should only give access privilege if access is allowed successfully or no error is produced.

So to avoid this flaw the code is altered as:

DWORD dwRet = IsAccessAllowed(...);

If (dwRet = ACCESS_ALLOWED) {

//Security check OK.

} else {

//Security check failed.

//Inform user that access is denied.

}

This will only allow access if ACCESS_ALLOWED evaluates to true and success is checked instead of failure here

You can also alter the if condition as:

If (dwRet = No_Error)

or

If (dwRet = 0)

The above if conditions checks if the access is allowed or if no error is produced. Only then it will allowed access otherwise not. So the access check is a success is checked first and failure (for any reason). The user is allowed access only if there is no error otherwise user is not allowed access.

You might be interested in
Signs that a listener is paying attention include:
Tomtit [17]
Eye contact, Taking notes, being quiet.I mean there is a lot of ways
6 0
3 years ago
Read 2 more answers
Who here watches obx, Riverdale or on my block?
melomori [17]

Answer:

Riverdale i watch it!

Explanation:

3 0
2 years ago
Read 2 more answers
Anyone got an xb0x and wann be friends 16+
Amiraneli [1.4K]

Answer:pointsssExplanation:

4 0
3 years ago
Read 2 more answers
50PTS!! does anyone know how you turn in a section of your slides my teacher wants us to turn in only a portion of our google sl
HACTEHA [7]

Answer:

The best way to turn in one part of google slides, since you can't split the slide when turning assignments on classroom, is to copy and paste the part you want to turn in into another slide and submit that portion. I've done for many projects before and if you name the different slides (Ex: Assignment Portion One 5/6/20) so it won't get confusing with the multiple slides.

This is the best way I can think of, I hope I helped, and please correct me if there is a better way!

5 0
3 years ago
What type of dns servers field dns queries, send iterative queries to upstream dns servers, or send requests to forwarders and t
photoshop1234 [79]

Answer:

catching only server to send iterative queries to upstream DNS servers, or send requests to forwarders

<h3>what DNS server normally sends iterative questions with another DNS server?</h3>
  • The DNS server sends an iterative query to a root server.
  • The root server responds with a referral to the top-level domain server address. a. Client's DNS server, with the top-level domain server address, generates a new iterative query and sends it to the top-level domain server.

To learn more about DNS servers, refer

to brainly.com/question/2051280

#SPJ4

6 0
2 years ago
Other questions:
  • How often should administrators and network users be required to change their password?
    10·1 answer
  • When using the boolean data type, we encapsulate the data in what symbol?
    11·2 answers
  • Which different supports from a part of the matte box?
    8·1 answer
  • How do i unblock website on my school computer
    7·2 answers
  • Data cannot be sorted or filterd accuratly if there are ________.
    12·1 answer
  • Is mmorpg an example of virtual community
    5·2 answers
  • A byte contains how many bits? Question 3 options:
    13·2 answers
  • What environmental hazards exist because of man’s desire for profit?
    11·2 answers
  • ________ was one of the first uses of the Internet
    15·2 answers
  • Edhesive in JAVA Write a method that takes a String parameter. If the String has a double letter (i.e. contains the same letter
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!