Uploaded image for project: 'Qpid Proton'
  1. Qpid Proton
  2. PROTON-2071

[Python] Proton integral type constructors and Data.put_*() methods need bounds checking

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: python-binding
    • Labels:
      None

      Description

      Using an out-of-bounds value to construct any integral type (except long) is simply accepted without an error:

      >>> proton.byte(12345)
      byte(12345)
      

      Using an out-of-bounds value (or an out-of-bounds integral type described above) on a Data.put_*() method results in an OverflowError:

      >>> d = proton.Data()
      >>> d.put_byte(12345)
      Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "/usr/lib64/proton/bindings/python/proton/_data.py", line 649, in put_byte
       self._check(pn_data_put_byte(self._data, b))
      OverflowError: in method 'pn_data_put_byte', argument 2 of type 'int8_t'
      

      A value range check needs to be made on all the integral constructors (except long which does not have this issue, and ulong which has already been fixed for negative values, see below) and Data.put_*() methods, and an AssertionError thrown if the supplied value is out-of-range.

      See PROTON-2038 for original limited fix for negative values on unsigned type constructors only.

        Attachments

          Activity

            People

            • Assignee:
              kpvdr Kim van der Riet
              Reporter:
              kpvdr Kim van der Riet
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: