Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-10719

Actual behavior of util_str2num is contrary to commented expectations

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Storage Engines
    • 5
    • StorEng - Defined Pipeline

      util_str2num contains the following commented code:

      /*
       * strtouq takes lots of things like hex values, signs and so on and so forth -- none of them
       * are OK with us. Check the string starts with digit, that turns off the special processing.
       */
      if (!__wt_isdigit((u_char)p[0]))
          goto format;
      
      errno = 0;
      v = __wt_strtouq(p, &endptr, 0);
      

      As base == 0 (last argument of {}wt_strtouq) the behavior of strtouq or strtoull invoked via }}{_}{{_wt_strtouq will be:

      • If the string has the prefix "0x" the number will be read in base 16.
      • If the string starts with "0' it will be read as octal.

      The guarding if statement that tests if the first character is a digit does not prevent either (1) or (2) above, but the comment indicates it should.

      Definition of Done

      1. Analyze calling code to determine intended behavior.
      2. Survey code to ensure that the implicit expectation that hex or octal cannot be used has not crept into scripts, tests, or any calling code.
      3. Bring comment and expected behavior into alignment. The exact solution will be dependent on results of (1) and (2).

            Assignee:
            backlog-server-storage-engines [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            marc.butler@mongodb.com Marc Butler
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: