wpa_supplicant can generate configs which it can't read back

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I believe this commit introduces a bug:
https://w1.fi/cgit/hostap/commit/src/utils/config.c?id=aca4d4963a65e49614ed8cd52836a2619775c1f6

Take for example this password:
    secret"#123

If you configure this password using wpa_cli, and save to a config file:
    wpa_cli set_network 0 psk '"secret"#123"'
    wpa_cli save_config

It generates a config file which looks something like this:
    network={
        psk="secret"#123"
    }

When restarting supplicant (or doing wpa_cli reconfigure), supplicant fails to read this config back,
because wpa_config_get_line uses strchr in a loop to find pairs of quotes, and checks if the # is
inside a pair of quotes:
             

         end of string
              |
              v
   psk="secret"#123"
       ^       ^^^^^
       |       comment
 start of string

But this doesn't match the way quotes are interpreted by the rest of the parser! If we look at
wpa_config_parse_str which calls wpa_config_parse_string, it strips the leftmost and rightmost
quote (using strrchr).

             end of string
                   |
                   v
   psk="secret"#123"
       ^
       | 
 start of string

(Of course, wpa_config_parse_string never gets to see anything past the #, since wpa_config_get_line
already has discarded that part of the string, since it thought it was a comment).


I'd suggest reverting the commit mentioned above.

Alternatively, if the config format needs to support comments containing quotes, the config format
maybe needs to be changed to escape quotes inside quotes (instead of using strrchr)?

Best regards,
Morten Solvang

_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux