Opened 2 years ago

Closed 2 years ago

#1325 closed Bug / Defect (fixed)

line counting for config file errors is wrong if inline material is used

Reported by: Gert Döring Owned by:
Priority: major Milestone: release 2.5
Component: Configuration Version: OpenVPN git master branch (Community Ed)
Severity: Not set (select this one, unless your'e a OpenVPN developer) Keywords: line numbers, inline
Cc: Antonio Quartulli, plaisthos


I have a config that happens to have <cert>, <key> etc. *before* the ifconfig stuff (usually it is the other way around), and there was a mistake

OpenVPN logs

Options error: Unrecognized option or missing or extra parameter(s) in standalone-server.ovpn:106: ifconfig-ipv6 (2.5_git)

but the actual line was like "300".

So it seems that inline material is only counted as "one line", and the line numbers are off afterwards.

Since this is confusing to users, it would be good to have fixed for 2.5.0

Change History (4)

comment:1 Changed 2 years ago by Gert Döring

Version: easyrsa master branchOpenVPN git master branch (Community Ed)

comment:2 Changed 2 years ago by Gert Döring

Cc: Antonio Quartulli plaisthos added

Looked through options.c a bit.

The call chain is (here)

read_config_file()     // read a line from file, increment line_num, and see if it 
                       // generally well_formed (parse_line()), then check for inline
                       // after inline check, do add_option()
check_inline_file_via_fp()   // do "check_inline_file" on a file pointer
check_inline_file()    // "is this <tag>?  if yes, return "true" and call
                       // read_line_file() to read all the lines (from fd or buf)
read_inline_file()     // do the "read and concatenate all lines until </tag> is found"
in_src_get()           // do the actual fgets()

the whole "check_inline*" call chain does not increment line_num or signal back the number of lines it has consumed.

I see two ways to approach this

  • pass an extra "int * inline_lines" argument that will be filled by read_line_file() and added to line_num later on
  • change the "bool" return type to "int" and overload the "is there inline?" with "is there inline, and if yes, how many lines?"

comment:4 Changed 2 years ago by Gert Döring

Resolution: fixed
Status: newclosed

commit a686f7e29af012783371f401f394ac1e62e5b75f (master)
commit 97af8b3101af6a1f8fef778d2c9e0e5f13d2d440 (release/2.5)
commit 8ce5a319fd7a9b13ed6fee92fbda567c24f832c5 (release/2.4)
Author: Gert Doering
Date: Sun Dec 6 13:57:11 2020 +0100

Fix line number reporting on config file errors after <inline> segments

Acked-by: Antonio Quartulli <antonio@…>
Message-Id: <20201206125711.12071-1-gert@…>

Note: See TracTickets for help on using tickets.