Merge lp:~stefanor/ibid/math-dos-381649 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Approved by: Jonathan Hitchcock
Approved revision: 643
Merged at revision: 659
Proposed branch: lp:~stefanor/ibid/math-dos-381649
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/math-dos-381649
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Michael Gorven Approve
Review via email: mp+6889@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote :

Changed the semantics a little. The main bug was not checking isinstance(arg, long). But I prefer this limiting function.

Revision history for this message
Michael Gorven (mgorven) wrote :

 review approve

review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ibid/plugins/math.py'
--- ibid/plugins/math.py 2009-05-02 16:33:45 +0000
+++ ibid/plugins/math.py 2009-05-29 13:38:36 +0000
@@ -76,9 +76,18 @@
76 pass76 pass
7777
78def limited_pow(*args):78def limited_pow(*args):
79 for arg, limit in zip(args, (1e100, 200)):79 "We don't want users to DOS the bot. Pow is the most dangerous function. Limit it"
80 if isinstance(arg, int) and (arg > limit or arg < -limit):80
81 raise LimitException81 # Are all the arguments ints?
82 if not [True for arg in args if not isinstance(arg, int) and not isinstance(arg, long)]:
83 try:
84 answer = pow(float(args[0]), float(args[1]))
85 if answer > 1e+300:
86 raise LimitException
87
88 except OverflowError, e:
89 raise LimitException(e)
90
82 return pow(*args)91 return pow(*args)
8392
84# ast method93# ast method

Subscribers

People subscribed via source and target branches