Skip to content

Commit 08efae8

Browse files
Prevent GSSError/_display_status() infinite recursion
I was unable to reproduce the problem, but this should prevent the issue. Resolves: #111
1 parent 79a1e35 commit 08efae8

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

gssapi/raw/misc.pyx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def _display_status(unsigned int error_code, bint is_major_code,
139139
whether or not to call again for further messages
140140
141141
Raises:
142-
GSSError
142+
ValueError
143143
"""
144144

145145
cdef int status_type
@@ -165,13 +165,15 @@ def _display_status(unsigned int error_code, bint is_major_code,
165165

166166
if maj_stat == GSS_S_COMPLETE:
167167
call_again = bool(msg_ctx_out)
168-
169168
msg_out = msg_buff.value[:msg_buff.length]
170169
gss_release_buffer(&min_stat, &msg_buff)
171170
return (msg_out, msg_ctx_out, call_again)
172171
else:
173-
# NB(directxman12): this is highly unlikely to cause a recursive loop
174-
raise GSSError(maj_stat, min_stat)
172+
# This hides whatever error gss_display_status is complaining about,
173+
# but obviates infinite recursion into stack exhaustion. The
174+
# exception raised here is handled by get_all_statuses(), which prints
175+
# the code.
176+
raise ValueError("gss_display_status call returned failure.")
175177

176178

177179
class GSSErrorRegistry(type):
@@ -294,18 +296,17 @@ class GSSError(Exception, metaclass=GSSErrorRegistry):
294296
try:
295297
msg, ctx, cont = _display_status(code, is_maj)
296298
res.append(msg.decode(msg_encoding))
297-
except GSSError:
298-
res.append(u'issue decoding code: {0}'.format(code))
299+
except ValueError as e:
300+
res.append(u'{0} Decoding code: {1}'.format(e, code))
299301
cont = False
300302

301303
while cont:
302304
try:
303305
msg, ctx, cont = _display_status(code, is_maj,
304306
message_context=ctx)
305307
res.append(msg.decode(msg_encoding))
306-
except GSSError:
307-
res.append(u'issue decoding '
308-
u'code: {0}'.format(code))
308+
except ValueError:
309+
res.append(u'{0} Decoding code: {1}'.format(e, code))
309310
cont = False
310311

311312
return res

0 commit comments

Comments
 (0)