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

_check_timestamp() doesn't raise error when timestamp is greater than current time #73

Open
vmm opened this issue Jun 16, 2011 · 0 comments
Labels
Milestone

Comments

@vmm
Copy link

vmm commented Jun 16, 2011

Looks like this method doesn't really care if the timestamp is pointing to distant future.

def _check_timestamp(self, timestamp):
    """Verify that timestamp is recentish."""
    timestamp = int(timestamp)
    now = int(time.time())
    lapsed = now - timestamp
    if lapsed > self.timestamp_threshold:
        raise Error('Expired timestamp: given %d and now %s has a '
            'greater difference than threshold %d' % (timestamp, now,
                self.timestamp_threshold))

If the timestamp is greater than current time, 'lapsed' variable will be negative, and therefore always false.

500 > 300
True
-500 > 300
False

I fixed it like this to my code:

if abs(lapsed) > self.timestamp_threshold:

@jaitaiwan jaitaiwan added the Bug label Jul 29, 2015
@jaitaiwan jaitaiwan added this to the 2.0 milestone Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants