Question: The beck exploit. A popular web server supports a function named no2s7ash() whose purpose is to collapse multiple / characters. For example, the string /d1///d2////d3/test.

The "beck" exploit. A popular web server supports a function named no2s7ash() whose purpose is to collapse multiple / characters. For example, the string /d1///d2////d3/test. htm1 collapses to \(/ \mathrm{d} 1 / \mathrm{d} 2 / \mathrm{d} 3 /\) test. htm 1 . The original algorithm was to repeatedly search for a / and copy the remainder of the string:

int n = name. length(); int i 1; while (i

Unfortunately, this code can takes quadratic time (for example, if the string consists of the / character repeated \(\mathrm{n}\) times). By sending multiple simultaneous requests with large numbers of / characters, a hacker could deluge the server and starve other processes for CPU time, thereby creating a denial-of-service attack. Develop a version of no2s7ash() that runs in linear time and does not allow for this type of attack.

int n = name. length(); int i 1; while (i

Step by Step Solution

3.48 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code snippet provided in the image is a naive implementation to collapse multiple characters into a single because it involves shifting the remain... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithm Design Questions!