Browse files

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


Signed-off-by: Heiko Hund <>
Acked-by: David Sommerseth <>
Signed-off-by: David Sommerseth <>
(cherry picked from commit 6e6f55f)
  • Loading branch information...
d12fk authored and David Sommerseth committed Feb 4, 2013
1 parent 901f647 commit a8fe779b04cc5bf698a1bf5bed4b0189126c3a38
Showing with 5 additions and 1 deletion.
  1. +5 −1 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);
- 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);

0 comments on commit a8fe779

Please sign in to comment.