Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix hash corruption in initFCMTokens() #425

Merged
merged 1 commit into from
Oct 30, 2022

Conversation

f3sty
Copy link
Contributor

@f3sty f3sty commented Oct 30, 2022

In initFCMTokens the call to gettimeofday() returns a two element array in this context, which then corrupts the active_connections element.
This in turn causes an invalid entry to be written to tokens.txt with an empty token value
e.g.

FCM token entry in @active_connections:

$VAR1 = \{
          '584809' => 'token',
          ' ' => 'pushstate',
          'id' => 1667001069,
          '1,6,3' => 'intlist',
          '3' => 'time',
          '0' => 'monlist',
          '1667001069' => 'badge',
          'android' => 'extra_fields',
          '30,10,30' => 'last_sent',
          'HASH(0x5640b83ec7b0)' => undef,
          'HASH(0x5640b820ed00)' => 'platform',
          'enabled' => 'appversion',
          'cNQdy3lhT8y0y1x...' => 'state',
          '1.6.009' => 'invocations',
          'type' => 1000
        };

tokens.txt:

{
  "tokens": {
    "cNQdy3lhT8y0y1x...": {
      "invocations": {
        "at": 9,
        "count": 0
      },
      "intlist": "30,10,30",
      "platform": "android",
      "monlist": "1,6,3",
      "appversion": "1.6.009",
      "pushstate": "enabled"
    },
    "": {                                   <---
      "invocations": {
        "at": 9,
        "count": 0
      }
    }
  }
}

Calling gettimeofday() in a scalar context produces a much happier looking hash:

$VAR1 = \{
            'monlist' => '1,6,3',
            'badge' => 0,
            'type' => 1000,
            'intlist' => '30,10,30',
            'time' => 1667001069,
            'id' => '1667001069',
            'extra_fields' => '',
            'state' => 3,
            'token' => 'cNQdy3lhT8y0y1x...',
            'last_sent' => {},
            'invocations' => {
                               'count' => 0,
                               'at' => 9
                             },
            'appversion' => '1.6.009',
            'platform' => 'android',
            'pushstate' => 'enabled'
          };

@baudneo
Copy link

baudneo commented Oct 30, 2022

Nice!

@connortechnology connortechnology merged commit 5dfc6c8 into ZoneMinder:master Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants