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

TypeError: Incorrect padding #46

Open
cedwards opened this issue Mar 17, 2015 · 1 comment
Open

TypeError: Incorrect padding #46

cedwards opened this issue Mar 17, 2015 · 1 comment

Comments

@cedwards
Copy link

I'm running d-note on CentOS 7 using uwsgi Emperor. I get the following exception in the /var/log/dnote.log:

[pid: 8395|app: 0|req: 13/58] 10.30.82.185 () {44 vars in 732 bytes} [Tue Mar 17 08:45:58 2015] GET /dnote/ => generated 4990 bytes in 386 msecs (HTTP/1.1 200) 2 headers in 81 bytes (1 switches on core 1)
ERROR:dnote:Exception on /on.ico [GET]
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/srv/http/dnote/dnote/__init__.py", line 62, in fetch_url
    note = Note(random_url)
  File "/srv/http/dnote/dnote/note.py", line 68, in __init__
    self.decode_url(url)
  File "/srv/http/dnote/dnote/note.py", line 111, in decode_url
    self.nonce = base64.urlsafe_b64decode(url.encode("utf-8"))
  File "/usr/lib64/python2.7/base64.py", line 112, in urlsafe_b64decode
    return b64decode(s, '-_')
  File "/usr/lib64/python2.7/base64.py", line 76, in b64decode
    raise TypeError(msg)
TypeError: Incorrect padding
@Thijssss
Copy link

Thijssss commented Jan 9, 2017

I ran in to this same issue. Apache cannot overwrite the DocumentError for WSGI unless its running as a deamon. I figured I would just patch it locally for now to get around the issue all together. I used a random word which works OK to get back a regular error message:

--- /linux/d-note-master/dnote/note.py  2015-10-29 21:16:22.000000000 +0100
+++ note.py     2017-01-09 11:51:28.030837067 +0100
@@ -108,8 +108,14 @@

         self.url = url
         url = url + "==" # add the padding back
-        self.nonce = base64.urlsafe_b64decode(url.encode("utf-8"))
-        self.f_key = KDF.PBKDF2(
+
+        try:
+               self.nonce = base64.urlsafe_b64decode(url.encode("utf-8"))
+       except:
+               url = "errormessage=="
+               self.nonce = base64.urlsafe_b64decode(url.encode("utf-8"))
+
+       self.f_key = KDF.PBKDF2(
             self.nonce, dconfig.nonce_salt.decode("hex"), 16)
         self.aes_key = KDF.PBKDF2(
             self.nonce, dconfig.aes_salt.decode("hex"), 32)

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

No branches or pull requests

2 participants