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

Consecutive stars in wildcardToRegularExpression cause regex catastrophic backtracking

XMLWordPrintable

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

      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;
      

        For Gerrit Dashboard: QTBUG-127672
        # Subject Branch Project Status CR V

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes