Someone pointed out that we eat \r's in apr_file_gets() ... now if we
respected the BINARY flag to open that might not be "as much" of
a problem - but it's deeper than that...
We also don't reassemble \r\n pairs in apr_file_puts() either, which
means any file that goes while(apr_file_gets()) apr_file_puts(); will
be corrupted. htpasswd.c is a good example of this.
Now one solution would be to respect the BINARY flag, but that
ignores the additional issue of APR_EOL_STR, and the Netware
implementation (Unix'es) that doesn't do anything like 'dropping'
\r's on the floor. It keeps them.
If we define APR_EOL_STR, then our API's should be returning
and assembling strings consistent with APR_EOL_STR, IMHO.
Any other opinions or should I go ahead and apply the attached
patch that doesn't do anything special with 'eliminating' \r's?
Bill
p.s. the code I believe could be affected today on Netware, and with
this patch on OS2/Win32 in the future...
mod_disk_cache.c lns 237, 260,
(ln 537 is good since scan_script_headers 'does the right thing' w.r.t. \r's
according to util_script.c ln 473)
mod_cgi.c ln 246 (similar in mod_cgid though it might only apply to Unix.)
mod_negotation.c (??? haven't reviewed in it's entirety)
ssl_engine_pphrase.c ln 629 (ewww)
And a few others... I simply grepped for apr_file_gets() and didn't drill into
every '\n' that might be ignoring the possibility of '\r'.
Index: file_io/os2/readwrite.c
===================================================================
RCS file: /home/cvs/apr/file_io/os2/readwrite.c,v
retrieving revision 1.56
diff -u -r1.56 readwrite.c
--- file_io/os2/readwrite.c 7 Jan 2003 00:52:51 -0000 1.56
+++ file_io/os2/readwrite.c 4 Mar 2003 18:01:49 -0000
@@ -343,9 +343,7 @@
break;
}
- if (str[i] == '\r' || str[i] == '\x1A')
- i--;
- else if (str[i] == '\n') {
+ if (str[i] == '\n') {
i++;
break;
}
Index: file_io/win32/readwrite.c
===================================================================
RCS file: /home/cvs/apr/file_io/win32/readwrite.c,v
retrieving revision 1.77
diff -u -r1.77 readwrite.c
--- file_io/win32/readwrite.c 24 Jan 2003 18:25:31 -0000 1.77
+++ file_io/win32/readwrite.c 4 Mar 2003 18:01:49 -0000
@@ -452,9 +452,7 @@
break;
}
- if (str[i] == '\r' || str[i] == '\x1A')
- i--; /* don't keep this char */
- else if (str[i] == '\n') {
+ if (str[i] == '\n') {
i++; /* don't clobber this char below */
break;
}