From f69656d00fe3154519ea21668d964bf8cc50c01b Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 10 Dec 2019 11:44:36 -0700 Subject: Handle CRLF when reading XML on Windows xml-support.c uses FOPEN_RT, but then reads the entire contents of the file and verifies that the number of bytes read matches the length. This can fail on Windows, where the read will translate line terminators. This patch fixes the bug by changing xml-support.c to use FOPEN_RB. This works because expat correctly handles \r\n line terminators. gdb/ChangeLog 2019-12-11 Tom Tromey * xml-support.c (xml_fetch_content_from_file): Use FOPEN_RB. gdb/testsuite/ChangeLog 2019-12-11 Tom Tromey * gdb.xml/tdesc-arch.exp (set_arch): Add "trans_mode" parameter. Add crlf test. Change-Id: I548438f33eed284dde1de8babf755eaa1a40319d --- gdb/xml-support.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gdb/xml-support.c') diff --git a/gdb/xml-support.c b/gdb/xml-support.c index f5a1427..0f0806f 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -977,11 +977,11 @@ xml_fetch_content_from_file (const char *filename, void *baton) { char *fullname = concat (dirname, "/", filename, (char *) NULL); - file = gdb_fopen_cloexec (fullname, FOPEN_RT); + file = gdb_fopen_cloexec (fullname, FOPEN_RB); xfree (fullname); } else - file = gdb_fopen_cloexec (filename, FOPEN_RT); + file = gdb_fopen_cloexec (filename, FOPEN_RB); if (file == NULL) return {}; -- cgit v1.1