Blame SOURCES/python-gssapi-display_status-infinite-recursion.patch

3fd62d
From b7e6c6c5451590f18df965a2a84550a63461d76e Mon Sep 17 00:00:00 2001
3fd62d
From: Robbie Harwood <rharwood@redhat.com>
3fd62d
Date: Mon, 27 Mar 2017 13:24:37 -0400
3fd62d
Subject: [PATCH] Prevent GSSError/_display_status() infinite recursion
3fd62d
3fd62d
I was unable to reproduce the problem, but this should prevent the issue.
3fd62d
3fd62d
Resolves: #111
3fd62d
---
3fd62d
 gssapi/raw/misc.pyx | 20 +++++++++++---------
3fd62d
 1 file changed, 11 insertions(+), 9 deletions(-)
3fd62d
3fd62d
diff --git a/gssapi/raw/misc.pyx b/gssapi/raw/misc.pyx
3fd62d
index e278c4b..4ea0c55 100644
3fd62d
--- a/gssapi/raw/misc.pyx
3fd62d
+++ b/gssapi/raw/misc.pyx
3fd62d
@@ -139,7 +139,7 @@ def _display_status(unsigned int error_code, bint is_major_code,
3fd62d
             whether or not to call again for further messages
3fd62d
 
3fd62d
     Raises:
3fd62d
-       GSSError
3fd62d
+       ValueError
3fd62d
     """
3fd62d
 
3fd62d
     cdef int status_type
3fd62d
@@ -165,13 +165,16 @@ def _display_status(unsigned int error_code, bint is_major_code,
3fd62d
 
3fd62d
     if maj_stat == GSS_S_COMPLETE:
3fd62d
         call_again = bool(msg_ctx_out)
3fd62d
-
3fd62d
         msg_out = msg_buff.value[:msg_buff.length]
3fd62d
         gss_release_buffer(&min_stat, &msg_buff)
3fd62d
         return (msg_out, msg_ctx_out, call_again)
3fd62d
     else:
3fd62d
-        # NB(directxman12): this is highly unlikely to cause a recursive loop
3fd62d
-        raise GSSError(maj_stat, min_stat)
3fd62d
+        # This hides whatever error gss_display_status is complaining about,
3fd62d
+        # but obviates infinite recursion into stack exhaustion.  The
3fd62d
+        # exception raised here is handled by get_all_statuses(), which prints
3fd62d
+        # the code.
3fd62d
+        raise ValueError("gss_display_status call returned failure "
3fd62d
+                         "(major {0}, minor {1}).".format(maj_stat, min_stat))
3fd62d
 
3fd62d
 
3fd62d
 class GSSErrorRegistry(type):
3fd62d
@@ -294,8 +297,8 @@ class GSSError(Exception, metaclass=GSSErrorRegistry):
3fd62d
         try:
3fd62d
             msg, ctx, cont = _display_status(code, is_maj)
3fd62d
             res.append(msg.decode(msg_encoding))
3fd62d
-        except GSSError:
3fd62d
-            res.append(u'issue decoding code: {0}'.format(code))
3fd62d
+        except ValueError as e:
3fd62d
+            res.append(u'{0}  Decoding code: {1}'.format(e, code))
3fd62d
             cont = False
3fd62d
 
3fd62d
         while cont:
3fd62d
@@ -303,9 +306,8 @@ class GSSError(Exception, metaclass=GSSErrorRegistry):
3fd62d
                 msg, ctx, cont = _display_status(code, is_maj,
3fd62d
                                                  message_context=ctx)
3fd62d
                 res.append(msg.decode(msg_encoding))
3fd62d
-            except GSSError:
3fd62d
-                res.append(u'issue decoding '
3fd62d
-                           u'code: {0}'.format(code))
3fd62d
+            except ValueError:
3fd62d
+                res.append(u'{0}  Decoding code: {1}'.format(e, code))
3fd62d
                 cont = False
3fd62d
 
3fd62d
         return res
3fd62d
-- 
3fd62d
2.11.0
3fd62d