[krbdev.mit.edu #7760] [PATCH] Don't assume function arguments are evaluated right-to-left

Mark H Weaver via RT rt-comment at krbdev.mit.edu
Thu Nov 7 11:43:25 EST 2013


On mips64el-linux-gnu (using the MIPS N32 ABI), GCC 4.7.3 reports that
'context' is used before it is initialized in the first statement of
'main' in src/lib/krb5/krb/t_cc_config.c.

Indeed, the code assumes that function arguments will be evaluated in
right-to-left order.  I see nothing in the relevant C standards that
would justify this assumption.  C99 section 6.5.2.3 paragraph 10 states:

   The order of evaluation of the function designator, the actual
   arguments, and subexpressions within the actual arguments is
   unspecified, but there is a sequence point before the actual call.

The same paragraph of C11 is worded differently, but amounts to the same
thing: "There is a sequence point after the evaluations of the function
designator and the actual arguments but before the actual call."  There
is no mention of any other sequence points.

The following patch fixes this problem.

   Regards,
     Mark


--- src/lib/krb5/krb/t_cc_config.c.orig	2012-12-17 21:47:05.000000000 -0500
+++ src/lib/krb5/krb/t_cc_config.c	2013-10-29 18:19:16.547994590 -0400
@@ -117,8 +117,8 @@
     int c;
     unsigned int i;
 
-    bail_on_err(context, "Error initializing Kerberos library",
-                krb5_init_context(&context));
+    ret = krb5_init_context(&context);
+    bail_on_err(context, "Error initializing Kerberos library", ret);
     bail_on_err(context, "Error getting location of default ccache",
                 krb5_cc_default(context, &ccache));
     server = NULL;



More information about the krb5-bugs mailing list