Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-17787

CommandLineToArgvW quotes parse inaccurate implementation

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Untriaged
    • Priority: Minor
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      https://github.com/reactos/reactos/blob/master/dll/win32/shell32/wine/shell32_main.c#L80

      Seems the function incorrectly parses sequence of quotes like `abc"""`

      I've found it when have run a set of tests:

      https://github.com/andry81/contools/blob/cb9c6a9962e9f7846b57b9c2067c79aff392df06/Utilities/tests/TODO.txt

      Specifically these tests has failed:

      printargs "0 1"" 2
      printargs "0 1""" 2
      

      The printargs utility just simply prints it's own command line:

      https://github.com/andry81/contools/blob/697dc55a313474fc1478c06c3cbc96eed8948908/Utilities/src/printargs/printargs.cpp

      Piece of code with the fix is here:

      https://github.com/andry81/contools/blob/9070c155775983394a414e26fa067a729ba2ec84/Utilities/src/_common/common.hpp#L3165

      The function _get_cmdline_arg_offsets just converts an array of argument indexes into an array of argument offsets in the initial command line.

      The actual piece of code which had a bug:

                  else if (*s == L'"')
                  {
                      quote_count = 0;
       
                      if (!(backslash_count & 1))
                          quote_count++; // unescaped
       
                      s++;
                      backslash_count = 0;
       
                      while (*s == L'"')
                      {
                          quote_count++;
                          s++;
                      }
       
                      if (quote_count & 1) {
                          quote_open = !quote_open;
                      }
                  }
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              andry81 andry81
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: