Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-127672

Consecutive stars in wildcardToRegularExpression cause regex catastrophic backtracking

    XMLWordPrintable

Details

    • a041cd352 (dev), 4c1a82e4c (6.8), 3bb0cb673 (dev)

    Description

      Reporting here an issue that has been reported in a qBittorent issue, see this comment.

      If the input to QRegularExpression::wildcardToRegularExpression (browse code) contains multiple consecutive stars (i.e. ****), it may cause catastrophic backtracking when using the resulting regex.

      Of course, the problem worsens as the amount of consecutive stars increases, easily hanging the program. And often, the end user can control the input...

      This issue can easily be solved by merging the consecutive stars into a single .*, as so:

              case '*':
                  rx += settings.starEscape;
      +++         while (i < wclen && wc[i] == u'*') {
      +++             ++i;
      +++         }
                  break;
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            peppe Giuseppe D'Angelo
            pineapple John Doe
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes