rupa / sprunge

command line pastebin for google appengine
http://sprunge.us
724 stars 70 forks source link

Infinite loop in post() after 62^4 pastes? #38

Open mk-pmb opened 7 years ago

mk-pmb commented 7 years ago

Thanks for hosting this very efficient pastebin!

Reading the code I found that you're probably set up to encounter the length vs. dupes problem once your service becomes more popular. The retry without feedback (ln 85 post()) with fixed identifier length (ln 21 new_id()) will become slow (even infinite at 62^4 ≈ 14M) and drain your randomness pool.

Minor other stuff:

Since my suggested solutions turned out to all be more about generic random ID generators and not really project-specific, instead of a PR, I made the lib linked above so you can use it in all related projects if you like to, and anyone else, too. I cannot release it under WTFPL becuase of warranty and liability, but I grant you permission (in addition to those of ISC) to republish derivates of make-random-id-python under WTFPL.