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
Which best describes IMEI?
Delicious77 [7]

Answer:

A unique identifier for a mobile phone

Explanation:

There are different codes and tracking number assigned to different devices such as laptop, mobiles and other devices. The purpose of this task is to make sure the security of device in all aspects. The tracking number that is used to track mobile phone is named as IMEI that stands for International Mobile Equipment Identity.

IMEI is the the unique identity of mobile phone device that consists of 15 digits. It is the unique number that is assigned to phones.

8 0
3 years ago
In 1–2 sentences, describe how you would create a border around a group of cells
iragen [17]
Pick one of the cells you<span> want to format and then click the down arrow beside the </span>Borders<span> button in the Font </span>group<span> on the Home tab. A drop-down menu comes up with all the</span>border<span> options that </span>you can<span> apply to the </span>cell<span> selection</span>
4 0
3 years ago
Read 2 more answers
If you want to protect your identity while social networking, then you might use a(n) ____________ for your profile image
notsponge [240]
Won't you use a fake photo for your profile image or not put one on at all! This is a very safe way to keep your identity a secret and that you are very safe while you are online.

Hope this help!!
4 0
3 years ago
The operating systems_______ formats storage disks , lists, files, and deleting files
Misha Larkins [42]
Disk Operating System (D.O.S.) and if a Microsoft product it is known as MS-DOS (Microsoft Disk Operating System). Developed first for IBM by Microsoft, MS-DOS was the standard operating system for IBM-compatible personal computers.
8 0
4 years ago
Which of the following domestic appliances does not use a magnet?
alekssr [168]
Pressing iron isn’t domestic appliances
7 0
3 years ago
Read 2 more answers
Other questions:
  • Machine language library routines are installed on computers Select one: a. because they can come as part of the operating syste
    15·1 answer
  • Which font attribute would be most appropriate to make a papers heading stand out?
    7·2 answers
  • Write a program that generates 1,000 random integers between 0 and 9 and displays the count for each number. (Hint: Use a list o
    12·1 answer
  • The PICC team is scheduled to remove a PICC before client discharge. Assessment of the catheter indicates the PICC and determine
    7·1 answer
  • A store owner keeps a record of daily transactions in a text file. Each line contains three items: The invoice number, the cash
    7·1 answer
  • What are 25 items that trees made?
    6·2 answers
  • Fill in the blank with the correct response.
    7·1 answer
  • Convert 12 bits to bytes​
    13·1 answer
  • Uh can somebody help me
    6·1 answer
  • Ultraportable computers will often use ___ technology exclusively, even though their storage capacity is lower than that of a tr
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!