Skip to content

Prevent GSSError/_display_status() infinite recursion #112

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ F8_SETUP=$?
flake8 gssapi
F8_PY=$?

flake8 gssapi --filename='*.pyx,*.pxd' --ignore=E225,E226,E227,E901,E402
# Cython requires special flags since it is not proper Python
# E225: missing whitespace around operator
# E226: missing whitespace around arithmetic operator
# E227: missing whitespace around bitwise or shift operator
# E402: module level import not at top of file
# E901: SyntaxError or IndentationError
# E999: Internal AST compilation error (flake8 specific)
flake8 gssapi --filename='*.pyx,*.pxd' --ignore=E225,E226,E227,E402,E901,E999
F8_MAIN_CYTHON=$?

python setup.py nosetests --verbosity=3
Expand Down
20 changes: 11 additions & 9 deletions gssapi/raw/misc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _display_status(unsigned int error_code, bint is_major_code,
whether or not to call again for further messages

Raises:
GSSError
ValueError
"""

cdef int status_type
Expand All @@ -165,13 +165,16 @@ def _display_status(unsigned int error_code, bint is_major_code,

if maj_stat == GSS_S_COMPLETE:
call_again = bool(msg_ctx_out)

msg_out = msg_buff.value[:msg_buff.length]
gss_release_buffer(&min_stat, &msg_buff)
return (msg_out, msg_ctx_out, call_again)
else:
# NB(directxman12): this is highly unlikely to cause a recursive loop
raise GSSError(maj_stat, min_stat)
# This hides whatever error gss_display_status is complaining about,
# but obviates infinite recursion into stack exhaustion. The
# exception raised here is handled by get_all_statuses(), which prints
# the code.
raise ValueError("gss_display_status call returned failure "
"(major {0}, minor {1}).".format(maj_stat, min_stat))


class GSSErrorRegistry(type):
Expand Down Expand Up @@ -294,18 +297,17 @@ class GSSError(Exception, metaclass=GSSErrorRegistry):
try:
msg, ctx, cont = _display_status(code, is_maj)
res.append(msg.decode(msg_encoding))
except GSSError:
res.append(u'issue decoding code: {0}'.format(code))
except ValueError as e:
res.append(u'{0} Decoding code: {1}'.format(e, code))
cont = False

while cont:
try:
msg, ctx, cont = _display_status(code, is_maj,
message_context=ctx)
res.append(msg.decode(msg_encoding))
except GSSError:
res.append(u'issue decoding '
u'code: {0}'.format(code))
except ValueError:
res.append(u'{0} Decoding code: {1}'.format(e, code))
cont = False

return res
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def gssapi_modules(lst):

return res


long_desc = re.sub('\.\. role:: \w+\(code\)\s*\n\s*.+', '',
re.sub(r':(python|bash|code):', '',
re.sub(r'\.\. code-block:: \w+', '::',
Expand Down