Fix incorrect macro guard in the UC3 EndpointStream header file.
[pub/USBasp.git] / Projects / Webserver / Lib / HTTPServerApp.c
index 1a9464e..6822b27 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2010.
+     Copyright (C) Dean Camera, 2011.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -181,7 +181,7 @@ static void HTTPServerApp_OpenRequestedFile(void)
        }
 
        /* Copy over the requested filename */
        }
 
        /* Copy over the requested filename */
-       strncpy(AppState->HTTPServer.FileName, &RequestedFileName[1], (sizeof(AppState->HTTPServer.FileName) - 1));
+       strncpy(AppState->HTTPServer.FileName, &RequestedFileName[1], sizeof(AppState->HTTPServer.FileName));
 
        /* Ensure filename is null-terminated */
        AppState->HTTPServer.FileName[sizeof(AppState->HTTPServer.FileName) - 1] = 0x00;
 
        /* Ensure filename is null-terminated */
        AppState->HTTPServer.FileName[sizeof(AppState->HTTPServer.FileName) - 1] = 0x00;
@@ -190,11 +190,11 @@ static void HTTPServerApp_OpenRequestedFile(void)
        uint8_t FileNameLen = strlen(AppState->HTTPServer.FileName);
 
        /* If the URI is a directory, append the default filename */
        uint8_t FileNameLen = strlen(AppState->HTTPServer.FileName);
 
        /* If the URI is a directory, append the default filename */
-       if (AppState->HTTPServer.FileName[FileNameLen - 1] == '/')
+       if ((AppState->HTTPServer.FileName[FileNameLen - 1] == '/') || !(FileNameLen))
        {
                strncpy_P(&AppState->HTTPServer.FileName[FileNameLen], DefaultDirFileName,
                          (sizeof(AppState->HTTPServer.FileName) - FileNameLen));
        {
                strncpy_P(&AppState->HTTPServer.FileName[FileNameLen], DefaultDirFileName,
                          (sizeof(AppState->HTTPServer.FileName) - FileNameLen));
-
+               
                /* Ensure altered filename is still null-terminated */
                AppState->HTTPServer.FileName[sizeof(AppState->HTTPServer.FileName) - 1] = 0x00;
        }
                /* Ensure altered filename is still null-terminated */
                AppState->HTTPServer.FileName[sizeof(AppState->HTTPServer.FileName) - 1] = 0x00;
        }