]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Improve printf handling of size_t args
authorBen Kaduk <kaduk@mit.edu>
Wed, 27 Jun 2012 19:14:00 +0000 (15:14 -0400)
committerBen Kaduk <kaduk@mit.edu>
Mon, 2 Jul 2012 22:47:16 +0000 (18:47 -0400)
The %*s format takes two arguments, a precision length/width and
an actual string; the length is specified as a signed integer.
The size_t length field of the gss_buffer_desc type is an unsigned
type, which must be cast or otherwise converted to a signed type
to match the format string expectations.
I do not think that the length will approach SIZE_T_MAX in practice,
due to buffer constraints, so do not include handling for the
edge case.

There is a '%zu' format string for printing size_ts, but it is not
available everywhere (e.g., AIX).  Instead, use the
unsigned long long abomination.

src/appl/gss-sample/gss-server.c
src/lib/rpc/auth_gssapi_misc.c

index 2e56e06ab0202d35683c95d7a98994e8f8b4ed54..0f5fea0f81d668e7041ce7338e0fcc4779fe001d 100644 (file)
@@ -893,7 +893,7 @@ showLocalIdentity(OM_uint32 *minor, gss_name_t name)
 
     major = gss_localname(minor, name, GSS_C_NO_OID, &localname);
     if (major == GSS_S_COMPLETE)
-        printf("localname: %-*s\n", localname.length, localname.value);
+        printf("localname: %-*s\n", (int)localname.length, localname.value);
     else if (major != GSS_S_UNAVAILABLE)
         display_status("gss_localname", major, *minor);
     gss_release_buffer(minor, &localname);
index e1f92053d54b9f5be91717ecf34c093512443083..53bdb983c458245284a444832edb88d388bf7685 100644 (file)
@@ -183,7 +183,7 @@ static void auth_gssapi_display_status_1(
          putc ('\n', stderr);
          if (misc_debug_gssapi)
              gssrpcint_printf("GSS-API authentication error %s: %*s\n",
-                              m, msg.length, (char *) msg.value);
+                              m, (int)msg.length, (char *) msg.value);
          (void) gss_release_buffer(&minor_stat, &msg);
 
          if (!msg_ctx)
@@ -296,8 +296,9 @@ bool_t auth_gssapi_unwrap_data(
      if (*major != GSS_S_COMPLETE)
          return FALSE;
 
-     PRINTF(("gssapi_unwrap_data: %d bytes data, %d bytes sealed\n",
-            out_buf.length, in_buf.length));
+     PRINTF(("gssapi_unwrap_data: %llu bytes data, %llu bytes sealed\n",
+            (unsigned long long)out_buf.length,
+            (unsigned long long)in_buf.length));
 
      xdrmem_create(&temp_xdrs, out_buf.value, out_buf.length, XDR_DECODE);