Skip to content

wsl.conf: line continuation is broken when the file uses CRLF line endings #41590

Description

Windows Version

Not tied to a Windows version (found in the source, master at eaa69e7)

WSL Version

master at eaa69e7

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

No response

Distro Version

No response

Other Software

No response

Repro Steps

I noticed this while reading src/shared/configfile/configfile.cpp. Inside a value, an escaped \r is meant to be skipped as part of a CRLF line continuation, but only the \r is consumed. The \n that follows is read back by the value loop, which ends the value there.

Put this in /etc/wsl.conf with CRLF line endings (for example after editing it from Windows):

[boot]
command=echo a \
 b
[network]
hostname=foo

then restart the distribution.

Expected Behavior

Same result as with LF line endings: boot.command is echo a b and the hostname is foo.

Actual Behavior

boot.command is cut to echo a , the line b is parsed as a key with no =, and because the guest parses wsl.conf without CFG_SKIP_INVALID_LINES, parsing stops at that point. Everything after the continuation (here [network] hostname) is silently ignored.

I have not run this on a live WSL install. I compiled configfile.cpp on its own on Linux against the same content and got:

LF   result=0 command='echo a  b' hostname='foo'
CRLF result=-1 command='echo a ' hostname=''

Diagnostic Logs

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-investigationlikely actionable and/or needs more investigation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions