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
A TV game show Jeopardy! contestant who uses a strategy to seek out the hidden Daily Double questions, which are usually the thr
jek_recluse [69]

Answer:

Game theory.

Explanation:

In the TV game show Jeopardy! Game theory allows contestant to use a strategy to seek out the hidden Daily Double questions, instead of the more common approach of selecting a single category and selecting questions gradually increasing in the degree of difficulty.

Game theory is the process of using mathematical model in the study of strategic interaction between two or more players in a game or situation having laid down rules and outcomes.

8 0
3 years ago
The formula A$7+$D7in cell was copied to cell H10.write the formula as it would appear in cell H10
vitfil [10]

Answer:

H$7+$D10

Explanation:

$ means fixed. It won't change.

6 0
3 years ago
You're a volunteer at a local charity, and you've been asked to create a flyer for a fundraiser. The charity wants to send the f
amm1812

Since you aren't sure that all recipients have access to Microsoft Word, you should save the file by using the "Save as" command.

<h3>What is Microsoft Word?</h3>

Microsoft Word can be defined as a word-processing software program that is designed and developed by Microsoft Inc., so as to avail its end users an ability to type, format, adjust and save text-based documents or files.

<h3>What is a file?</h3>

A file can be defined as a computer resource or type of document that avails an end user the ability to save or record data as a single unit on a computer storage device.

In this scenario, we can infer and logically deduce that you should save the file by using the "Save as" command because you aren't sure that all recipients have access to Microsoft Word.

Read more on Microsoft Word here: brainly.com/question/25813601

#SPJ1

3 0
2 years ago
1. Trust can be built in a relationship if:
artcher [175]

Answer:

A

Explanation:

because if both parties feel safe communicating and feel understood by the other party they feel safe trusting the other person and it develops a trust worthy relationship

4 0
3 years ago
What should you do to organize a large amount of data??
Kay [80]
Set them up from least to greatest or create a number graph with all the data.
5 0
3 years ago
Other questions:
  • Who is demonstrating entrepreneurship?
    7·1 answer
  • How is steering different from turning ? Need help //:
    13·1 answer
  • While designing web pages for mobiles, the page content should be extensive such that the readers get the opportunity to explore
    5·2 answers
  • Which of the following was the first commercial software package to incorporate WYSIWYG as a feature?
    15·1 answer
  • *Could someone please help me with this***
    5·1 answer
  • FREE POINTS JUST ANSWER MY LATEST TWO QUESTIONS PLEASE
    10·2 answers
  • Briefly describe the interface between the memory and the processing unit. That is, describe the method by which the memory and
    6·1 answer
  • When creating a documentary, what is not an appropriate source for footage?
    11·1 answer
  • Although plants and ainamals are both living things___
    13·1 answer
  • Data files whose records are always retrieved in sequence from the beginning of the file are known as
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!