]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
rewrite CR mitigation logic to wipe out any trailing
authorJeff Trawick <trawick@apache.org>
Sun, 11 Sep 2005 12:35:56 +0000 (12:35 +0000)
committerJeff Trawick <trawick@apache.org>
Sun, 11 Sep 2005 12:35:56 +0000 (12:35 +0000)
white space

Suggested by: wrowe

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@280114 13f79535-47bb-0310-9956-ffa450edef68

modules/metadata/mod_mime_magic.c

index f4ca7207b2ad8a171a2bdd560077c7a9205d57b7..d0f485fac19efe8787dba03345df8bb3731a210c 100644 (file)
@@ -947,16 +947,16 @@ static int apprentice(server_rec *s, apr_pool_t *p)
     /* parse it */
     for (lineno = 1; apr_file_gets(line, BUFSIZ, f) == APR_SUCCESS; lineno++) {
        int ws_offset;
-        char *last = line + strlen(line) - 1; /* guaranteed that len >= 1 */
+        char *last = line + strlen(line) - 1; /* guaranteed that len >= 1 since an
+                                               * "empty" line contains a '\n'
+                                               */
 
-       /* delete newline and potential carriage return */
-        if (*last == '\n') {
+       /* delete newline and any other trailing whitespace */
+        while (last >= line
+               && apr_isspace(*last)) {
             *last = '\0';
             --last;
         }
-        if (*last == '\r') {
-            *last = '\0';
-        }
         
        /* skip leading whitespace */
        ws_offset = 0;