Changeset 881


Ignore:
Timestamp:
02/12/14 12:37:37 (10 years ago)
Author:
jts21
Message:

Fix bug in ImageServer which caused exceptions to be thrown when an unknown image was requested from the server (was non-fatal, so the bug fix is really just tidying up the console output). Also fix more serious bug in ImageSaver where existing images would be overwritten if a client tried to upload a file with the same name (could not occur through an existing codepath in Expeditee, but was exploitable by using external software to send custom data). Now the new file is ignored (not entirely ideal since it's probably a good idea to let the client know if their copy of an image differs from the server's copy... maybe have them send checksums of the files to compare and print a warning message if the files are different?)

Location:
trunk/src/org/expeditee/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/network/ImageSaver.java

    r878 r881  
    2121        // if the above reads failed, fileLen will be -1
    2222        if(fileLen <= 0) {
     23                return false;
     24        }
     25        if(file.exists()) {
     26                System.out.println("Ignoring " + file.getName() + " (already exists on filesystem)");
     27                is.skip(fileLen);
    2328                return false;
    2429        }
  • trunk/src/org/expeditee/network/ImageServer.java

    r878 r881  
    1414       
    1515        public static void sendImage(File file, Socket socket) throws IOException {
     16                if(!file.isFile()) {
     17                        System.out.println("Could not find " + file.getName());
     18                        return;
     19                }
    1620                OutputStream os = socket.getOutputStream();
    1721        // send the file over the socket
Note: See TracChangeset for help on using the changeset viewer.