Skip to content

INSTANCE_ID can be out of bound #4

Description

@maxfischer2781

On startup, ApMon creates an instance identifier using ApMon.__getInstanceID. This can create an identifier that is out of the 32bit integer range. Sending reports then fails, as the value cannot be packed:

ERROR: [ApMon] Error in sendBgMonitoring: 'l' format requires -2147483648 <= number <= 2147483647
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/apmon.py", line 407, in sendBgMonitoring
  self.__directSendParams(destination, self.__defaultSysMonCluster, self.__defaultSysMonNode, -1, sysResults)
File "/usr/lib/python2.7/site-packages/apmon.py", line 795, in __directSendParams
  hdrPacker.pack_int(crtSenderRef['INSTANCE_ID'])
File "/usr/lib64/python2.7/xdrlib.py", line 57, in pack_int
  self.__buf.write(struct.pack('>l', x))
error: 'l' format requires -2147483648 <= number <= 2147483647

The cause appears to be in ApMon.__getInstanceID. The identifier is created from (pid << 16) | (ip << 8) | rnd. Any pid above 32767 automatically causes the result to be greater than 2147483647.

A simple fix would to wrap either the pid or instance identifier to the valid range of values. Alternatively, a portion of a hash (md5, sha1, ...) of the information could do as well. I do not know whether this must be consistent with other Apmon clients, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions