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

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