diff options
author | Heiko Hund <heiko.hund@sophos.com> | 2013-02-04 11:39:25 +0000 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2013-02-06 20:02:09 +0100 |
commit | 6e6f55f4ba5deda5649679a13e4e323e07b3e661 (patch) | |
tree | 3a6fb076cbe485958ba213a34c34519862b2beef /src | |
parent | 607a678d371c56d368319b0a7a1bb147008d5822 (diff) | |
download | openvpn-6e6f55f4ba5deda5649679a13e4e323e07b3e661.tar.gz openvpn-6e6f55f4ba5deda5649679a13e4e323e07b3e661.tar.xz openvpn-6e6f55f4ba5deda5649679a13e4e323e07b3e661.zip |
Ignore UTF-8 byte order mark
Currently openvpn exits when reading configuration from a file
that has an UTF-8 byte order mark (EF BB BF) at its start.
While it is useless to put a BOM into UTF-8 encoded files, the
Unicode standard [1] permits it (on page 36):
"Use of a BOM is neither required nor recommended for UTF-8,
but may be encountered in contexts where UTF-8 data is converted
from other encoding forms that use a BOM or where the BOM is
used as a UTF-8 signature."
Notepad.exe, the default text editor on Windows, always puts the BOM
into UTF-8 encoded files when saving them. Others may do as well.
Just ignoring the UTF-8 BOM will make config files with UTF-8 BOM
readable.
[1] http://www.unicode.org/versions/Unicode5.0.0/ch02.pdf
Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: David Sommerseth <davids@redhat.com>
Message-Id: 1359977966-31724-1-git-send-email-heiko.hund@sophos.com
URL: http://article.gmane.org/gmane.network.openvpn.devel/7342
Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/openvpn/options.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 8ca41a3..3b5f1e7 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -3771,9 +3771,13 @@ read_config_file (struct options *options, line_num = 0; while (fgets(line, sizeof (line), fp)) { + int offset = 0; CLEAR (p); ++line_num; - if (parse_line (line, p, SIZE (p), file, line_num, msglevel, &options->gc)) + /* Ignore UTF-8 BOM at start of stream */ + if (line_num == 1 && strncmp (line, "\xEF\xBB\xBF", 3) == 0) + offset = 3; + if (parse_line (line + offset, p, SIZE (p), file, line_num, msglevel, &options->gc)) { bypass_doubledash (&p[0]); check_inline_file_via_fp (fp, p, &options->gc); |