New version page

UConn CSE 2102 - Homework #6

Documents in this Course
Load more

Previewing page 1


Unformatted text preview:

CSE 3100 Systems ProgrammingHomework #6 Due: 10/30/2018 11/8/2018Complete your work in the hw6 folder. Remember to pull, add, commit, and push.Note: For this homework you will work on a project that has multiple source files. Study the Makefileand learn how to write rules for such targets.An implementation of a TFTP server and client has been demonstrated in the lecture. In this assignmentyou extend the functionality of the server and client programs. Descriptive error messages should be providedwhen commands cannot be executed. Assume filenames do not have white spaces and cannot be longer than255 characters. The length of the files can be represented by a 32 bit integer. Both the server and clientshould only read/write files under the directory where they start. In general the two directories may not bethe same (indeed, the server and client may run on two different machines).Exercise 1. (20 points) Modify the server to take the port number as an optional command line argument,and the client to take as optional command line argument the host name, optionally followed by a portnumber. The default host name localhost and port 8080 should be used whenever these arguments are notspecified.Exercise 2. (20 points) Extend the client with a new lls command, which lists the content of the localdirectory (the directory in which the client is started). Recall that running the existing ls command liststhe content of the remote directory (the directory in which the server runs).Exercise 3. (20 points) Extend the client with two new commands, size and lsize, which display thesize in bytes for a file given as a command argument, in the remote and local directory, respectively.Exercise 4. (20 points) Extend the client with a new command, mget, which takes as argument a list offile names, separated by one or more spaces or tabs, and transfers the files in the specified order from theserver to the client. The file names may be specified on the same line as the mget command. If no filenameis specified on the same line as mget, the client asks the user to enter one or more filenames on the next line.You can implement this command by repeating the provided get command.Exercise 5. (20 points) Improve the code with more error checking, careful string handling, and inputvalidation (especially on the server side). The example code is written for the purposes of demonstratingsocket programming. It does not check the return value of some function calls and has some vulnerabilitiesthat are easy to fix. More specifically, improve the code by fixing the following issues.1. The client uses scanf("%s") to read strings, which may result in buffer overflow.2. The server does not sanitize the filenames received from the client. Currently, the filename may notbe NUL terminated and the client can specify filenames like "/etc/passwd".3. Ther server does not report some of the errors. If there is an error, the server should abort the executionof the current command and report error messages to the client.You are encouraged to identify and fix more


View Full Document
Loading Unlocking...
Login

Join to view Homework #6 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework #6 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?