[28330] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit: Fix t_marshal on big-endian platforms

daemon@ATHENA.MIT.EDU (Greg Hudson)
Mon May 19 10:17:29 2014

Date: Mon, 19 May 2014 10:17:21 -0400
From: Greg Hudson <ghudson@mit.edu>
Message-Id: <201405191417.s4JEHLUQ001220@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/cacdcf8ebe184326579fabef3ae3f86b16dade81
commit cacdcf8ebe184326579fabef3ae3f86b16dade81
Author: Greg Hudson <ghudson@mit.edu>
Date:   Sun May 18 16:40:35 2014 -0400

    Fix t_marshal on big-endian platforms
    
    t_marshal.c attempts to skip the version 1 and 2 tests on big-endian
    platforms, but didn't do so correctly.  Correctly start at version 3
    on big-endian platforms, and change the way we do it to avoid
    preprocessor conditionals inside a function body.

 src/lib/krb5/ccache/t_marshal.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/lib/krb5/ccache/t_marshal.c b/src/lib/krb5/ccache/t_marshal.c
index 07685d6..d6908da 100644
--- a/src/lib/krb5/ccache/t_marshal.c
+++ b/src/lib/krb5/ccache/t_marshal.c
@@ -36,6 +36,17 @@
 #include <arpa/inet.h>
 #include <fcntl.h>
 
+/*
+ * Versions 1 and 2 of the ccache format use native byte order representations
+ * of integers.  The test data below is from a little-endian platform.  Skip
+ * those tests on big-endian platforms by starting at version 3.
+ */
+#ifdef K5_BE
+#define FIRST_VERSION 3
+#else
+#define FIRST_VERSION 1
+#endif
+
 /* Each test contains the expected binary representation of a credential cache
  * divided into the header, the default principal, and two credentials. */
 const struct test {
@@ -275,13 +286,8 @@ main(int argc, char **argv)
     if (krb5_init_context(&context) != 0)
         abort();
 
-    for (version = 1; version <= 4; version++) {
+    for (version = FIRST_VERSION; version <= 4; version++) {
         t = &tests[version - 1];
-#ifdef K5_BE
-        /* The version 1 and 2 test data use little-endian integers. */
-        if (version == 0 || version == 1)
-            continue;
-#endif
 
         /* Test principal unmarshalling and marshalling. */
         if (k5_unmarshal_princ(t->princ, t->princlen, version, &princ) != 0)
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post