From: Jeff Trawick Date: Sun, 11 Sep 2005 12:35:56 +0000 (+0000) Subject: rewrite CR mitigation logic to wipe out any trailing X-Git-Tag: 2.3.0~3008 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfe0b8a4ff0321404520051e441ef51c43f24198;p=thirdparty%2Fapache%2Fhttpd.git rewrite CR mitigation logic to wipe out any trailing white space Suggested by: wrowe git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@280114 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/metadata/mod_mime_magic.c b/modules/metadata/mod_mime_magic.c index f4ca7207b2a..d0f485fac19 100644 --- a/modules/metadata/mod_mime_magic.c +++ b/modules/metadata/mod_mime_magic.c @@ -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;