nus (iii) Explain three additional checks that a web server may…

Question Answered step-by-step nus (iii) Explain three additional checks that a web server may… nus(iii) Explain three additional checks that a web server may implement to reduce this risk? [6 marks] 8 CST1.2019.4.9 7 Security (a) In a Linux shell session, you can see the following information: $ ls -la drwxr-xr-x 2 root root 4096 Jun 3 13:29 . drwxr-xr-x 25 root root 4096 Jun 3 13:29 .. -rwxr-xr-x 1 root root 4675 Jun 3 in order to achieve the following additional goals: • Only members of the group staff who are not also members of the group interns can execute script.pl. • When script.pl is called, it should be able to switch between using the access privileges of the caller and those of the user primary. • All members of group staff should be able to read the contents of script.pl. What would “ls -la” output after you have applied these changes? [6 marks] (b) Sending a password over a network connection is vulnerable to replay attacks by eavesdroppers. Briefly describe three other forms of unilateral (or one-pass) authentication suitable for human keyboard entry that reduce that risk with the help of a hardware token, and name one advantage of each. [6 marks] (c) The Windows NT operating-system family offers two variants of many API functions that receive a string: one for strings using ASCII (or one of its 8-bit “code page” extensions) and one for 16-bit Unicode strings. Linux and many Internet protocols instead use an ASCII-compatible encoding of Unicode called UTF-8. (i) Briefly explain how UTF-8 is decoded. [4 marks] (ii) What particular security risk can emerge when UTF-8 is used in a system along with another Unicode encoding, such as the 16-bit wide characters on Windows, and how can this be avoided?tackle every question ) How is inheritance of class variables typically implemented by a compiler for an object-oriented language in which each class has exactly one parent? [3 marks] (b) When supporting multiple inheritance, what extra run-time complexity arises when casting or coercing an object handle up or down and why is this avoided using the Java concept of an interface? [3 marks] (c) When supporting multiple inheritance, what identifier clash problem can arise and what are the possible solutions? [4 marks] (d) Explain, using an example, the potential for an erroneous downcast in an object-oriented language such as Java, C++ or C#. [4 marks] (e) Sketch assembly-level code that (i) detects an erroneous downcast; (ii) finds an exception handler for it; and (iii) correctly jumps to the handler. Assume that the handler is already registered with the run-time system and that there are no arguments to the exception. Use any well-known implementation techniques, such as keeping an object’s identity in its virtual method table and stacking exception handlers on an extra run-time stack. [6 marks] 4 CST.2010.3.5 5 Concepts in Programming Languages (a) List two differences between the programming languages FORTRAN and Pascal. [4 marks] (b) List two differences between the programming languages SIMULA and Smalltalk. [4 marks] (c) Explain what is understood by type checking and by type inference in the context of programming languages. Compare the two approaches, presenting their advantages and disadvantages. [4 marks] (d) Give an example in the SML Modules language of a signature and of a structure. State whether or not the structure matches the signature, explaining your answer. [4 marks] (e) The programming language Scala introduced case classes. Explain why they are useful in programming, giving code samples.  In the Pac Man game.  need Pacman to run the maze on his own and collect all the dots. Pacman is stuck in a loop on the top left of the corner after clearing some of the dots.  fix it. if((lastAction == NOTHING) || (lastAction == Pac.E)) {   if (isPossibleToDoAction(Pac.E)){               pacman.actions[0] = Pac.E;   performAction(Pac.E);         }   else if (isPossibleToDoAction(Pac.S)){               pacman.actions[0] = Pac.S;   performAction(Pac.S);         }   else if (isPossibleToDoAction(Pac.N)){   pacman.actions[0] = Pac.N;   performAction(Pac.N);         }   }   else if(lastAction == Pac.S) {   if (isPossibleToDoAction(Pac.S)){   pacman.actions[0] = Pac.S;   performAction(Pac.S);         }   else if (isPossibleToDoAction(Pac.W)){   pacman.actions[0] = Pac.W;   performAction(Pac.W);         }   else if (isPossibleToDoAction(Pac.E)){               pacman.actions[0] = Pac.E;   performAction(Pac.E);         }   }   else if(lastAction == Pac.W) {   if (isPossibleToDoAction(Pac.W)){               pacman.actions[0] = Pac.W;   performAction(Pac.W);         }   else if (isPossibleToDoAction(Pac.N)){               pacman.actions[0] = Pac.N;   performAction(Pac.N);         }   else if (isPossibleToDoAction(Pac.S)){               pacman.actions[0] = Pac.S;   performAction(Pac.S);         }   }   else if(lastAction == Pac.N) {   if (isPossibleToDoAction(Pac.N)){               pacman.actions[0] = Pac.N;   performAction(Pac.N);         }   else if (isPossibleToDoAction(Pac.W)){               pacman.actions[0] = Pac.W;   performAction(Pac.W);         }   else if (isPossibleToDoAction(Pac.E)){               pacman.actions[0] = Pac.E;   performAction(Pac.E);         }   }  Write  Python function, called counting, that takes two arguments (a string and an integer), and returns the number of digits in the string argument that are not the same as the integer argument.Create  recursive method that takes as input the root Node of a tree and returns true if the N variable of each node within that tree has the correct valueCreate  function that takes a list and an integer v, and returns True if v is in the list (False otherwise). The function should be efficient and stop searching as soon as possible.Write  program that contains the following functions a) A function that takes in as input the amount a person has to pay to buy a house, and the monthly payments made. Your function should display how much has been payed and how much is left to pay every month until the mortgage has been In the IEEE binary floating-point Standard (IEEE 754), what exponent and significand are used in representing each of the numbers 0, 1 and 2 in single precision? How are the exponent and significand stored in each case? [6 marks] Show the 32 bits that represent (1+macheps). What is the exact value of macheps in this case. Consider the following structure declaration for a general directed graph data structure. In this structure, the size field gives the number of outgoing edges, and the children field is a pointer to an array of pointers to the child nodes. typedef struct node Node; struct node { bool flag; int size; Node **children; // pointer to an array of Node pointers }; (a) Define a function Node *node(int n, Node **children) which builds a new node from its arguments, taking ownership of the children argument and initializing the flag field to false. [2 marks] (b) Write a function Node *example(void) which returns a new graph with the following structure, with the return value corresponding to n1: [2 marks] n1 n2 (c) Define a structure for representing a linked list of Node * pointers, with a Nodelist typedef for the structure. [2 marks] (d) Supposing we represent the empty linked list with the NULL pointer, and a cons cell with a pointer to a Nodelist, define a function Nodelist *cons(Node *head, Nodelist *tail) to add an element to this linked list. [2 marks] (e) Write a function Nodelist *reachable(Node *node) which returns a list of all the nodes reachable from the argument node, including node itself. This list should contain every reachable node, and have no duplicates. You may assume that the flag field of every reachable node is set to false on entry to this function, and that your routine may modify it as you wish. [7 marks] (f ) Define a function void free node(Node *node) which deallocates all the node objects reachable from the argument node. You may assume that the flag field of every reachable node is set to false on entry to this function, and that your routine may modify it as you wish. [5 marks] 2 CST1.2019.4.3 2 Programming in C and C++ (a) Find at least 2 sources of undefined behaviour in the following program, and write a corrected version of this function. [5 marks] int main(void) { char *s = “abcde”; int len = strlen(s); for (int i = 0; i <= len; i++) s[i] += 1; return printf("'%s' is %d characters longn", ++s, strlen(s)); } (b) Restructure the program below to be more cache-efficient, giving the code and explaining your changes. [5 marks] typedef struct point { double x, y, z; } Point; int find_max_x_argument(int n, Point *elems) { double max = 0; int max_index = 0; for (int i = 0; i < n; i++) if (max < elems[i].x) { max_index = i; max = elems[i].x; } return max_index; } (c) The following definition forms part of a legal C++ program: int foo() { MyClass x(1,2); MyClass y = C(3,4); MyClass z = x; MyClass t; z = x; z.f = x.f; return z.f; } (i) Give a declaration of MyClass which enables foo to compile and run, noting any methods or constructors in MyClass which are invoked when foo is called. [Note: Precise C++ syntax is not necessary to obtain full marks.] [4 marks] (ii) Having seen your declaration of MyClass, a colleague points out some of the lines of foo may be redundant. Which are these? [2 marks] (iii) Your boss now replaces your declaration of MyClass. Not having access to the new declaration, explain, giving reasons, which if any lines of foo are now redundant. [4 marks] 3 (TURN OVER) CST1.2019.4.4 3 Compiler Construction We will extend our language SLANG and the JARGON virtual machine with data type definitions such as type int_list = Nil | Cons of int * int_list type int_tree = Leaf of int | Node of int * int_tree * int_tree (Note that we will not consider polymorphic types.) Computer Science Engineering & Technology C++ Programming NETWORKING MISC Share QuestionEmailCopy link Comments (0)