krb5 commit: Modernize k5buf

Greg Hudson ghudson at MIT.EDU
Thu Feb 14 11:43:20 EST 2013


https://github.com/krb5/krb5/commit/6dda284554a869f7fa1e6d2a035df06c97f103ef
commit 6dda284554a869f7fa1e6d2a035df06c97f103ef
Author: Greg Hudson <ghudson at mit.edu>
Date:   Thu Feb 14 11:41:10 2013 -0500

    Modernize k5buf
    
    Rename the krb5int_buf_ family of functions to use the k5_ prefix for
    brevity.  Reformat some k5buf implementation code to match current
    practices.

 src/clients/ksu/authorization.c                    |   10 +-
 src/include/k5-buf.h                               |   75 ++++----
 src/lib/crypto/crypto_tests/t_hmac.c               |    8 +-
 src/lib/crypto/krb/cf2.c                           |   14 +-
 src/lib/gssapi/generic/gssapiP_generic.h           |    6 +-
 src/lib/gssapi/generic/oid_ops.c                   |   12 +-
 src/lib/gssapi/mechglue/g_export_cred.c            |   14 +-
 src/lib/kadm5/alt_prof.c                           |   12 +-
 src/lib/kadm5/str_conv.c                           |   10 +-
 src/lib/kdb/kdb5.c                                 |   20 +-
 src/lib/krb5/krb/chpw.c                            |   52 +++---
 src/lib/krb5/krb/gic_opt.c                         |   12 +-
 src/lib/krb5/krb/srv_rcache.c                      |   16 +-
 src/lib/krb5/os/an_to_ln.c                         |   10 +-
 src/lib/krb5/os/dnsglue.c                          |   12 +-
 src/lib/krb5/os/dnssrv.c                           |   12 +-
 src/lib/krb5/os/expand_path.c                      |   12 +-
 src/lib/krb5/os/sendto_kdc.c                       |   20 +-
 src/lib/krb5/os/trace.c                            |   79 ++++----
 src/lib/krb5/rcache/rc_dfl.c                       |   44 ++--
 src/plugins/kdb/ldap/libkdb_ldap/ldap_principal.c  |   10 +-
 src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c      |    8 +-
 src/plugins/preauth/pkinit/pkinit_crypto_nss.c     |   35 ++--
 src/plugins/preauth/pkinit/pkinit_crypto_openssl.c |   35 ++--
 src/util/gss-kernel-lib/t_kgss_user.c              |   12 +-
 src/util/support/json.c                            |   38 ++--
 src/util/support/k5buf-int.h                       |   11 +-
 src/util/support/k5buf.c                           |   57 ++++--
 src/util/support/libkrb5support-fixed.exports      |   18 +-
 src/util/support/t_k5buf.c                         |  208 ++++++++++---------
 30 files changed, 443 insertions(+), 439 deletions(-)

diff --git a/src/clients/ksu/authorization.c b/src/clients/ksu/authorization.c
index f1cc8ac..7f393b8 100644
--- a/src/clients/ksu/authorization.c
+++ b/src/clients/ksu/authorization.c
@@ -513,12 +513,12 @@ krb5_boolean find_first_cmd_that_exists(fcmd_arr, cmd_out, err_out)
     }
 
     if (retbool == FALSE ){
-        krb5int_buf_init_dynamic(&buf);
-        krb5int_buf_add(&buf, _("Error: not found -> "));
+        k5_buf_init_dynamic(&buf);
+        k5_buf_add(&buf, _("Error: not found -> "));
         for(j= 0; j < i; j ++)
-            krb5int_buf_add_fmt(&buf, " %s ", fcmd_arr[j]);
-        krb5int_buf_add(&buf, "\n");
-        *err_out = krb5int_buf_data(&buf);
+            k5_buf_add_fmt(&buf, " %s ", fcmd_arr[j]);
+        k5_buf_add(&buf, "\n");
+        *err_out = k5_buf_data(&buf);
         if (*err_out == NULL) {
             perror(prog_name);
             exit(1);
diff --git a/src/include/k5-buf.h b/src/include/k5-buf.h
index 621d7d3..c5576a3 100644
--- a/src/include/k5-buf.h
+++ b/src/include/k5-buf.h
@@ -66,68 +66,65 @@ struct k5buf {
     size_t xx_len;
 };
 
-/** Initialize a k5buf using a fixed-sized, existing buffer.  SPACE must be
+/* Initialize a k5buf using a fixed-sized, existing buffer.  SPACE must be
  * more than zero, or an assertion failure will result. */
-void krb5int_buf_init_fixed(struct k5buf *buf, char *data, size_t space);
+void k5_buf_init_fixed(struct k5buf *buf, char *data, size_t space);
 
-/** Initialize a k5buf using an internally allocated dynamic buffer.  The
- * buffer contents must be freed with krb5int_free_buf. */
-void krb5int_buf_init_dynamic(struct k5buf *buf);
+/* Initialize a k5buf using an internally allocated dynamic buffer.  The
+ * buffer contents must be freed with k5_free_buf. */
+void k5_buf_init_dynamic(struct k5buf *buf);
 
-/** Add a C string to BUF. */
-void krb5int_buf_add(struct k5buf *buf, const char *data);
+/* Add a C string to BUF. */
+void k5_buf_add(struct k5buf *buf, const char *data);
 
-/**
+/*
  * Add a counted set of bytes to BUF.  It is okay for DATA[0..LEN-1]
  * to contain null bytes if you are prepared to deal with that in the
- * output (use krb5int_buf_len to retrieve the length of the output).
+ * output (use k5_buf_len to retrieve the length of the output).
  */
-void krb5int_buf_add_len(struct k5buf *buf, const char *data, size_t len);
+void k5_buf_add_len(struct k5buf *buf, const char *data, size_t len);
 
-/** Add sprintf-style formatted data to BUF. */
-void krb5int_buf_add_fmt(struct k5buf *buf, const char *fmt, ...)
+/* Add sprintf-style formatted data to BUF. */
+void k5_buf_add_fmt(struct k5buf *buf, const char *fmt, ...)
 #if !defined(__cplusplus) && (__GNUC__ > 2)
     __attribute__((__format__(__printf__, 2, 3)))
 #endif
     ;
 
-/** Truncate BUF.  LEN must be between 0 and the existing buffer
+/* Truncate BUF.  LEN must be between 0 and the existing buffer
  * length, or an assertion failure will result. */
-void krb5int_buf_truncate(struct k5buf *buf, size_t len);
+void k5_buf_truncate(struct k5buf *buf, size_t len);
 
-/**
+/*
  * Retrieve the byte array value of BUF, or NULL if there has been an
  * allocation failure or the fixed buffer ran out of room.
-
+ *
  * The byte array will be a C string unless binary data was added with
- * krb5int_buf_add_len; it will be null-terminated regardless.
- * Modifying the byte array does not invalidate the buffer, as long as
- * its length is not changed.
-
- * For a fixed buffer, the return value will always be equal to the
- * passed-in value of DATA at initialization time if it is not NULL.
-
+ * k5_buf_add_len; it will be null-terminated regardless.  Modifying the byte
+ * array does not invalidate the buffer, as long as its length is not changed.
+ *
+ * For a fixed buffer, the return value will always be equal to the passed-in
+ * value of DATA at initialization time if it is not NULL.
+ *
  * For a dynamic buffer, any buffer modification operation except
- * krb5int_buf_truncate may invalidate the byte array address.
+ * k5_buf_truncate may invalidate the byte array address.
  */
-char *krb5int_buf_data(struct k5buf *buf);
+char *k5_buf_data(struct k5buf *buf);
 
-/**
- * Retrieve the length of BUF, or -1 if there has been an allocation
- * failure or the fixed buffer ran out of room.  The length is equal
- * to strlen(krb5int_buf_data(buf)) unless binary data was added with
- * krb5int_buf_add_len.
+/*
+ * Retrieve the length of BUF, or -1 if there has been an allocation failure or
+ * the fixed buffer ran out of room.  The length is equal to
+ * strlen(k5_buf_data(buf)) unless binary data was added with k5_buf_add_len.
  */
-ssize_t krb5int_buf_len(struct k5buf *buf);
+ssize_t k5_buf_len(struct k5buf *buf);
 
-/**
- * Free the storage used in the dynamic buffer BUF.  The caller may
- * choose to take responsibility for freeing the return value of
- * krb5int_buf_data instead of using this function.  If BUF is a fixed
- * buffer, an assertion failure will result.  It is unnecessary
- * (though harmless) to free a buffer after an error is detected; the
- * storage will already have been freed in that case.
+/*
+ * Free the storage used in the dynamic buffer BUF.  The caller may choose to
+ * take responsibility for freeing the return value of k5_buf_data instead of
+ * using this function.  If BUF is a fixed buffer, an assertion failure will
+ * result.  It is unnecessary (though harmless) to free a buffer after an error
+ * is detected; the storage will already have been freed in that case.
  */
-void krb5int_free_buf(struct k5buf *buf);
+void k5_free_buf(struct k5buf *buf);
 
 #endif /* K5_BUF_H */
diff --git a/src/lib/crypto/crypto_tests/t_hmac.c b/src/lib/crypto/crypto_tests/t_hmac.c
index 02168e5..cd79dc3 100644
--- a/src/lib/crypto/crypto_tests/t_hmac.c
+++ b/src/lib/crypto/crypto_tests/t_hmac.c
@@ -247,11 +247,11 @@ static void test_hmac()
             exit(1);
         }
 
-        krb5int_buf_init_fixed(&buf, stroutbuf, sizeof(stroutbuf));
-        krb5int_buf_add(&buf, "0x");
+        k5_buf_init_fixed(&buf, stroutbuf, sizeof(stroutbuf));
+        k5_buf_add(&buf, "0x");
         for (j = 0; j < out.length; j++)
-            krb5int_buf_add_fmt(&buf, "%02x", 0xff & outbuf[j]);
-        if (krb5int_buf_data(&buf) == NULL)
+            k5_buf_add_fmt(&buf, "%02x", 0xff & outbuf[j]);
+        if (k5_buf_data(&buf) == NULL)
             abort();
         if (strcmp(stroutbuf, md5tests[i].hexdigest)) {
             printf("*** CHECK FAILED!\n"
diff --git a/src/lib/crypto/krb/cf2.c b/src/lib/crypto/krb/cf2.c
index 1d0a01b..e6d990c 100644
--- a/src/lib/crypto/krb/cf2.c
+++ b/src/lib/crypto/krb/cf2.c
@@ -46,9 +46,9 @@ prf_plus(krb5_context context, krb5_keyblock *k, const char *pepper,
     char *buffer = NULL;
     struct k5buf prf_inbuf;
 
-    krb5int_buf_init_dynamic(&prf_inbuf);
-    krb5int_buf_add_len(&prf_inbuf, "\001", 1);
-    krb5int_buf_add(&prf_inbuf, pepper);
+    k5_buf_init_dynamic(&prf_inbuf);
+    k5_buf_add_len(&prf_inbuf, "\001", 1);
+    k5_buf_add(&prf_inbuf, pepper);
     retval = krb5_c_prf_length( context, k->enctype, &prflen);
     if (retval)
         goto cleanup;
@@ -59,12 +59,12 @@ prf_plus(krb5_context context, krb5_keyblock *k, const char *pepper,
     buffer = k5alloc(iterations * prflen, &retval);
     if (retval)
         goto cleanup;
-    if (krb5int_buf_len(&prf_inbuf) == -1) {
+    if (k5_buf_len(&prf_inbuf) == -1) {
         retval = ENOMEM;
         goto cleanup;
     }
-    in_data.length = (krb5_int32) krb5int_buf_len(&prf_inbuf);
-    in_data.data = krb5int_buf_data(&prf_inbuf);
+    in_data.length = (krb5_int32)k5_buf_len(&prf_inbuf);
+    in_data.data = k5_buf_data(&prf_inbuf);
     out_data.length = prflen;
     out_data.data = buffer;
 
@@ -82,7 +82,7 @@ prf_plus(krb5_context context, krb5_keyblock *k, const char *pepper,
 
 cleanup:
     free(buffer);
-    krb5int_free_buf(&prf_inbuf);
+    k5_free_buf(&prf_inbuf);
     return retval;
 }
 
diff --git a/src/lib/gssapi/generic/gssapiP_generic.h b/src/lib/gssapi/generic/gssapiP_generic.h
index 63b7bf4..ebc9096 100644
--- a/src/lib/gssapi/generic/gssapiP_generic.h
+++ b/src/lib/gssapi/generic/gssapiP_generic.h
@@ -276,8 +276,8 @@ k5buf_to_gss(OM_uint32 *minor,
              gss_buffer_t output_buffer)
 {
     OM_uint32 status = GSS_S_COMPLETE;
-    char *bp = krb5int_buf_data(input_k5buf);
-    output_buffer->length = krb5int_buf_len(input_k5buf);
+    char *bp = k5_buf_data(input_k5buf);
+    output_buffer->length = k5_buf_len(input_k5buf);
 #if defined(_WIN32) || defined(DEBUG_GSSALLOC)
     if (output_buffer->length > 0) {
         output_buffer->value = gssalloc_malloc(output_buffer->length);
@@ -290,7 +290,7 @@ k5buf_to_gss(OM_uint32 *minor,
     } else {
         output_buffer->value = NULL;
     }
-    krb5int_free_buf(input_k5buf);
+    k5_free_buf(input_k5buf);
 #else
     output_buffer->value = bp;
     /*
diff --git a/src/lib/gssapi/generic/oid_ops.c b/src/lib/gssapi/generic/oid_ops.c
index a03b6f8..1229f38 100644
--- a/src/lib/gssapi/generic/oid_ops.c
+++ b/src/lib/gssapi/generic/oid_ops.c
@@ -257,8 +257,8 @@ generic_gss_oid_to_str(OM_uint32 *minor_status,
 
     cp = (unsigned char *) oid->elements;
     number = (unsigned long) cp[0];
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add(&buf, "{ ");
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add(&buf, "{ ");
     number = 0;
     cp = (unsigned char *) oid->elements;
     first = 1;
@@ -267,16 +267,16 @@ generic_gss_oid_to_str(OM_uint32 *minor_status,
         if ((cp[i] & 0x80) == 0) {
             if (first) {
                 n = (number < 40) ? 0 : (number < 80) ? 1 : 2;
-                krb5int_buf_add_fmt(&buf, "%lu %lu ", n, number - (n * 40));
+                k5_buf_add_fmt(&buf, "%lu %lu ", n, number - (n * 40));
                 first = 0;
             } else {
-                krb5int_buf_add_fmt(&buf, "%lu ", number);
+                k5_buf_add_fmt(&buf, "%lu ", number);
             }
             number = 0;
         }
     }
-    krb5int_buf_add_len(&buf, "}\0", 2);
-    if (krb5int_buf_data(&buf) == NULL) {
+    k5_buf_add_len(&buf, "}\0", 2);
+    if (k5_buf_data(&buf) == NULL) {
         *minor_status = ENOMEM;
         return(GSS_S_FAILURE);
     }
diff --git a/src/lib/gssapi/mechglue/g_export_cred.c b/src/lib/gssapi/mechglue/g_export_cred.c
index de2e98d..16d1ebe 100644
--- a/src/lib/gssapi/mechglue/g_export_cred.c
+++ b/src/lib/gssapi/mechglue/g_export_cred.c
@@ -73,7 +73,7 @@ gss_export_cred(OM_uint32 * minor_status, gss_cred_id_t cred_handle,
     if (status != GSS_S_COMPLETE)
         return status;
 
-    krb5int_buf_init_dynamic(&buf);
+    k5_buf_init_dynamic(&buf);
 
     cred = (gss_union_cred_t) cred_handle;
     for (i = 0; i < cred->count; i++) {
@@ -98,21 +98,21 @@ gss_export_cred(OM_uint32 * minor_status, gss_cred_id_t cred_handle,
 
         /* Append the mech OID and token to buf. */
         store_32_be(public_oid->length, lenbuf);
-        krb5int_buf_add_len(&buf, lenbuf, 4);
-        krb5int_buf_add_len(&buf, public_oid->elements, public_oid->length);
+        k5_buf_add_len(&buf, lenbuf, 4);
+        k5_buf_add_len(&buf, public_oid->elements, public_oid->length);
         store_32_be(mech_token.length, lenbuf);
-        krb5int_buf_add_len(&buf, lenbuf, 4);
-        krb5int_buf_add_len(&buf, mech_token.value, mech_token.length);
+        k5_buf_add_len(&buf, lenbuf, 4);
+        k5_buf_add_len(&buf, mech_token.value, mech_token.length);
         gss_release_buffer(&tmpmin, &mech_token);
     }
 
-    if (krb5int_buf_data(&buf) == NULL) {
+    if (k5_buf_data(&buf) == NULL) {
         *minor_status = ENOMEM;
         return GSS_S_FAILURE;
     }
     return k5buf_to_gss(minor_status, &buf, token);
 
 error:
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
     return status;
 }
diff --git a/src/lib/kadm5/alt_prof.c b/src/lib/kadm5/alt_prof.c
index 07158fc..bd1b8c8 100644
--- a/src/lib/kadm5/alt_prof.c
+++ b/src/lib/kadm5/alt_prof.c
@@ -75,16 +75,16 @@ krb5_aprof_init(char *fname, char *envname, krb5_pointer *acontextp)
         return ret;
     if (envname == NULL || (kdc_config = getenv(envname)) == NULL)
         kdc_config = fname;
-    krb5int_buf_init_dynamic(&buf);
+    k5_buf_init_dynamic(&buf);
     if (kdc_config)
-        krb5int_buf_add(&buf, kdc_config);
+        k5_buf_add(&buf, kdc_config);
     for (i = 0; filenames[i] != NULL; i++) {
-        if (krb5int_buf_len(&buf) > 0)
-            krb5int_buf_add(&buf, ":");
-        krb5int_buf_add(&buf, filenames[i]);
+        if (k5_buf_len(&buf) > 0)
+            k5_buf_add(&buf, ":");
+        k5_buf_add(&buf, filenames[i]);
     }
     krb5_free_config_files(filenames);
-    profile_path = krb5int_buf_data(&buf);
+    profile_path = k5_buf_data(&buf);
     if (profile_path == NULL)
         return ENOMEM;
     profile = (profile_t) NULL;
diff --git a/src/lib/kadm5/str_conv.c b/src/lib/kadm5/str_conv.c
index cdd2786..a490f14 100644
--- a/src/lib/kadm5/str_conv.c
+++ b/src/lib/kadm5/str_conv.c
@@ -183,18 +183,18 @@ krb5_flags_to_string(flags, sep, buffer, buflen)
 
     pflags = 0;
     sepstring = (sep) ? sep : flags_default_sep;
-    krb5int_buf_init_fixed(&buf, buffer, buflen);
+    k5_buf_init_fixed(&buf, buffer, buflen);
     /* Blast through the table matching all we can */
     for (i=0; i<flags_table_nents; i++) {
         if (flags & flags_table[i].fl_flags) {
-            if (krb5int_buf_len(&buf) > 0)
-                krb5int_buf_add(&buf, sepstring);
-            krb5int_buf_add(&buf, _(flags_table[i].fl_output));
+            if (k5_buf_len(&buf) > 0)
+                k5_buf_add(&buf, sepstring);
+            k5_buf_add(&buf, _(flags_table[i].fl_output));
             /* Keep track of what we matched */
             pflags |= flags_table[i].fl_flags;
         }
     }
-    if (krb5int_buf_data(&buf) == NULL)
+    if (k5_buf_data(&buf) == NULL)
         return(ENOMEM);
 
     /* See if there's any leftovers */
diff --git a/src/lib/kdb/kdb5.c b/src/lib/kdb/kdb5.c
index e1ee5f9..e1a7c5d 100644
--- a/src/lib/kdb/kdb5.c
+++ b/src/lib/kdb/kdb5.c
@@ -2101,37 +2101,37 @@ krb5_dbe_set_string(krb5_context context, krb5_db_entry *entry,
     code = begin_attrs(context, entry, &pos, &end);
     if (code)
         return code;
-    krb5int_buf_init_dynamic(&buf);
+    k5_buf_init_dynamic(&buf);
     while (next_attr(&pos, end, &mapkey, &mapval)) {
         if (strcmp(mapkey, key) == 0) {
             if (value != NULL) {
-                krb5int_buf_add_len(&buf, mapkey, strlen(mapkey) + 1);
-                krb5int_buf_add_len(&buf, value, strlen(value) + 1);
+                k5_buf_add_len(&buf, mapkey, strlen(mapkey) + 1);
+                k5_buf_add_len(&buf, value, strlen(value) + 1);
             }
             found = TRUE;
         } else {
-            krb5int_buf_add_len(&buf, mapkey, strlen(mapkey) + 1);
-            krb5int_buf_add_len(&buf, mapval, strlen(mapval) + 1);
+            k5_buf_add_len(&buf, mapkey, strlen(mapkey) + 1);
+            k5_buf_add_len(&buf, mapval, strlen(mapval) + 1);
         }
     }
 
     /* If key wasn't found in the map, add a new entry for it. */
     if (!found && value != NULL) {
-        krb5int_buf_add_len(&buf, key, strlen(key) + 1);
-        krb5int_buf_add_len(&buf, value, strlen(value) + 1);
+        k5_buf_add_len(&buf, key, strlen(key) + 1);
+        k5_buf_add_len(&buf, value, strlen(value) + 1);
     }
 
-    len = krb5int_buf_len(&buf);
+    len = k5_buf_len(&buf);
     if (len == -1)
         return ENOMEM;
     if (len > 65535)
         return KRB5_KDB_STRINGS_TOOLONG;
     tl_data.tl_data_type = KRB5_TL_STRING_ATTRS;
-    tl_data.tl_data_contents = (krb5_octet *)krb5int_buf_data(&buf);
+    tl_data.tl_data_contents = (krb5_octet *)k5_buf_data(&buf);
     tl_data.tl_data_length = len;
 
     code = krb5_dbe_update_tl_data(context, entry, &tl_data);
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
     return code;
 }
 
diff --git a/src/lib/krb5/krb/chpw.c b/src/lib/krb5/krb/chpw.c
index beb77cb..76f415d 100644
--- a/src/lib/krb5/krb/chpw.c
+++ b/src/lib/krb5/krb/chpw.c
@@ -382,8 +382,8 @@ struct ad_policy_info {
 static void
 add_spaces(struct k5buf *buf)
 {
-    if (krb5int_buf_len(buf) > 0)
-        krb5int_buf_add(buf, "  ");
+    if (k5_buf_len(buf) > 0)
+        k5_buf_add(buf, "  ");
 }
 
 static krb5_error_code
@@ -422,52 +422,48 @@ decode_ad_policy_info(const krb5_data *data, char **msg_out)
     /* Check that we processed exactly the expected number of bytes. */
     assert(p == data->data + AD_POLICY_INFO_LENGTH);
 
-    krb5int_buf_init_dynamic(&buf);
+    k5_buf_init_dynamic(&buf);
 
     /*
      * Update src/tests/misc/test_chpw_message.c if changing these strings!
      */
 
     if (policy.password_properties & AD_POLICY_COMPLEX) {
-        krb5int_buf_add(&buf,
-                        _("The password must include numbers or symbols.  "
-                          "Don't include any part of your name in the "
-                          "password."));
+        k5_buf_add(&buf, _("The password must include numbers or symbols.  "
+                           "Don't include any part of your name in the "
+                           "password."));
     }
     if (policy.min_length_password > 0) {
         add_spaces(&buf);
-        krb5int_buf_add_fmt(&buf,
-                            ngettext("The password must contain at least %d "
-                                     "character.",
-                                     "The password must contain at least %d "
-                                     "characters.",
-                                     policy.min_length_password),
-                            policy.min_length_password);
+        k5_buf_add_fmt(&buf, ngettext("The password must contain at least %d "
+                                      "character.",
+                                      "The password must contain at least %d "
+                                      "characters.",
+                                      policy.min_length_password),
+                       policy.min_length_password);
     }
     if (policy.password_history) {
         add_spaces(&buf);
-        krb5int_buf_add_fmt(&buf,
-                            ngettext("The password must be different from the "
-                                     "previous password.",
-                                     "The password must be different from the "
-                                     "previous %d passwords.",
-                                     policy.password_history),
-                            policy.password_history);
+        k5_buf_add_fmt(&buf, ngettext("The password must be different from "
+                                      "the previous password.",
+                                      "The password must be different from "
+                                      "the previous %d passwords.",
+                                      policy.password_history),
+                       policy.password_history);
     }
     if (policy.min_passwordage) {
         password_days = policy.min_passwordage / AD_POLICY_TIME_TO_DAYS;
         if (password_days == 0)
             password_days = 1;
         add_spaces(&buf);
-        krb5int_buf_add_fmt(&buf,
-                            ngettext("The password can only be changed once a "
-                                     "day.",
-                                     "The password can only be changed every "
-                                     "%d days.", (int)password_days),
-                            (int)password_days);
+        k5_buf_add_fmt(&buf, ngettext("The password can only be changed once "
+                                      "a day.",
+                                      "The password can only be changed every "
+                                      "%d days.", (int)password_days),
+                       (int)password_days);
     }
 
-    msg = krb5int_buf_data(&buf);
+    msg = k5_buf_data(&buf);
     if (msg == NULL)
         return ENOMEM;
 
diff --git a/src/lib/krb5/krb/gic_opt.c b/src/lib/krb5/krb/gic_opt.c
index 7a8750d..dddabf7 100644
--- a/src/lib/krb5/krb/gic_opt.c
+++ b/src/lib/krb5/krb/gic_opt.c
@@ -437,17 +437,17 @@ krb5_get_init_creds_opt_set_fast_ccache(krb5_context context,
     struct k5buf buf;
     char *cc_name;
 
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add(&buf, krb5_cc_get_type(context, ccache));
-    krb5int_buf_add(&buf, ":");
-    krb5int_buf_add(&buf, krb5_cc_get_name(context, ccache));
-    cc_name = krb5int_buf_data(&buf);
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add(&buf, krb5_cc_get_type(context, ccache));
+    k5_buf_add(&buf, ":");
+    k5_buf_add(&buf, krb5_cc_get_name(context, ccache));
+    cc_name = k5_buf_data(&buf);
     if (cc_name)
         retval = krb5_get_init_creds_opt_set_fast_ccache_name(context, opt,
                                                               cc_name);
     else
         retval = ENOMEM;
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
     return retval;
 }
 
diff --git a/src/lib/krb5/krb/srv_rcache.c b/src/lib/krb5/krb/srv_rcache.c
index d474fb6..1b0a91a 100644
--- a/src/lib/krb5/krb/srv_rcache.c
+++ b/src/lib/krb5/krb/srv_rcache.c
@@ -48,22 +48,22 @@ krb5_get_server_rcache(krb5_context context, const krb5_data *piece,
 
     cachetype = krb5_rc_default_type(context);
 
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add(&buf, cachetype);
-    krb5int_buf_add(&buf, ":");
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add(&buf, cachetype);
+    k5_buf_add(&buf, ":");
     for (i = 0; i < piece->length; i++) {
         if (piece->data[i] == '-')
-            krb5int_buf_add(&buf, "--");
+            k5_buf_add(&buf, "--");
         else if (!isvalidrcname((int) piece->data[i]))
-            krb5int_buf_add_fmt(&buf, "-%03o", piece->data[i]);
+            k5_buf_add_fmt(&buf, "-%03o", piece->data[i]);
         else
-            krb5int_buf_add_len(&buf, &piece->data[i], 1);
+            k5_buf_add_len(&buf, &piece->data[i], 1);
     }
 #ifdef HAVE_GETEUID
-    krb5int_buf_add_fmt(&buf, "_%lu", uid);
+    k5_buf_add_fmt(&buf, "_%lu", uid);
 #endif
 
-    cachename = krb5int_buf_data(&buf);
+    cachename = k5_buf_data(&buf);
     if (cachename == NULL)
         return ENOMEM;
 
diff --git a/src/lib/krb5/os/an_to_ln.c b/src/lib/krb5/os/an_to_ln.c
index 0f2600c..54b98f6 100644
--- a/src/lib/krb5/os/an_to_ln.c
+++ b/src/lib/krb5/os/an_to_ln.c
@@ -506,11 +506,11 @@ aname_get_selstring(krb5_context context, krb5_const_principal aname,
         return KRB5_LNAME_NOTRANS;
     current++;
 
-    krb5int_buf_init_dynamic(&selstring);
+    k5_buf_init_dynamic(&selstring);
     while (1) {
         /* Copy in literal characters up to the next $ or ]. */
         nlit = strcspn(current, "$]");
-        krb5int_buf_add_len(&selstring, current, nlit);
+        k5_buf_add_len(&selstring, current, nlit);
         current += nlit;
         if (*current != '$')
             break;
@@ -525,16 +525,16 @@ aname_get_selstring(krb5_context context, krb5_const_principal aname,
             : krb5_princ_realm(context, aname);
         if (!datap)
             break;
-        krb5int_buf_add_len(&selstring, datap->data, datap->length);
+        k5_buf_add_len(&selstring, datap->data, datap->length);
     }
 
     /* Check that we hit a ']' and not the end of the string. */
     if (*current != ']') {
-        krb5int_free_buf(&selstring);
+        k5_free_buf(&selstring);
         return KRB5_CONFIG_BADFORMAT;
     }
 
-    str = krb5int_buf_data(&selstring);
+    str = k5_buf_data(&selstring);
     if (str == NULL)
         return ENOMEM;
 
diff --git a/src/lib/krb5/os/dnsglue.c b/src/lib/krb5/os/dnsglue.c
index 6d11896..028d9c5 100644
--- a/src/lib/krb5/os/dnsglue.c
+++ b/src/lib/krb5/os/dnsglue.c
@@ -350,11 +350,11 @@ krb5_try_realm_txt_rr(const char *prefix, const char *name, char **realm)
      * Form our query, and send it via DNS
      */
 
-    krb5int_buf_init_fixed(&buf, host, sizeof(host));
+    k5_buf_init_fixed(&buf, host, sizeof(host));
     if (name == NULL || name[0] == '\0') {
-        krb5int_buf_add(&buf, prefix);
+        k5_buf_add(&buf, prefix);
     } else {
-        krb5int_buf_add_fmt(&buf, "%s.%s", prefix, name);
+        k5_buf_add_fmt(&buf, "%s.%s", prefix, name);
 
         /* Realm names don't (normally) end with ".", but if the query
            doesn't end with "." and doesn't get an answer as is, the
@@ -366,11 +366,11 @@ krb5_try_realm_txt_rr(const char *prefix, const char *name, char **realm)
            the local domain or domain search lists to be expanded.
         */
 
-        len = krb5int_buf_len(&buf);
+        len = k5_buf_len(&buf);
         if (len > 0 && host[len - 1] != '.')
-            krb5int_buf_add(&buf, ".");
+            k5_buf_add(&buf, ".");
     }
-    if (krb5int_buf_data(&buf) == NULL)
+    if (k5_buf_data(&buf) == NULL)
         return KRB5_ERR_HOST_REALM_UNKNOWN;
     ret = krb5int_dns_init(&ds, host, C_IN, T_TXT);
     if (ret < 0)
diff --git a/src/lib/krb5/os/dnssrv.c b/src/lib/krb5/os/dnssrv.c
index 4332ac7..33ee0e7 100644
--- a/src/lib/krb5/os/dnssrv.c
+++ b/src/lib/krb5/os/dnssrv.c
@@ -80,9 +80,9 @@ krb5int_make_srv_query_realm(const krb5_data *realm,
 
     if (memchr(realm->data, 0, realm->length))
         return 0;
-    krb5int_buf_init_fixed(&buf, host, sizeof(host));
-    krb5int_buf_add_fmt(&buf, "%s.%s.", service, protocol);
-    krb5int_buf_add_len(&buf, realm->data, realm->length);
+    k5_buf_init_fixed(&buf, host, sizeof(host));
+    k5_buf_add_fmt(&buf, "%s.%s.", service, protocol);
+    k5_buf_add_len(&buf, realm->data, realm->length);
 
     /* Realm names don't (normally) end with ".", but if the query
        doesn't end with "." and doesn't get an answer as is, the
@@ -93,11 +93,11 @@ krb5int_make_srv_query_realm(const krb5_data *realm,
        a search on the prefix alone then the intention is to allow
        the local domain or domain search lists to be expanded.  */
 
-    len = krb5int_buf_len(&buf);
+    len = k5_buf_len(&buf);
     if (len > 0 && host[len - 1] != '.')
-        krb5int_buf_add(&buf, ".");
+        k5_buf_add(&buf, ".");
 
-    if (krb5int_buf_data(&buf) == NULL)
+    if (k5_buf_data(&buf) == NULL)
         return 0;
 
 #ifdef TEST
diff --git a/src/lib/krb5/os/expand_path.c b/src/lib/krb5/os/expand_path.c
index 2da145f..3d23849 100644
--- a/src/lib/krb5/os/expand_path.c
+++ b/src/lib/krb5/os/expand_path.c
@@ -465,7 +465,7 @@ k5_expand_path_tokens_extra(krb5_context context, const char *path_in,
 
     *path_out = NULL;
 
-    krb5int_buf_init_dynamic(&buf);
+    k5_buf_init_dynamic(&buf);
 
     /* Count extra tokens. */
     va_start(ap, path_out);
@@ -497,10 +497,10 @@ k5_expand_path_tokens_extra(krb5_context context, const char *path_in,
          * If there are no more tokens, we can finish up. */
         tok_begin = strstr(path_left, "%{");
         if (tok_begin == NULL) {
-            krb5int_buf_add(&buf, path_left);
+            k5_buf_add(&buf, path_left);
             break;
         }
-        krb5int_buf_add_len(&buf, path_left, tok_begin - path_left);
+        k5_buf_add_len(&buf, path_left, tok_begin - path_left);
 
         /* Find the end of this token. */
         tok_end = strchr(tok_begin, '}');
@@ -515,12 +515,12 @@ k5_expand_path_tokens_extra(krb5_context context, const char *path_in,
                            &tok_val);
         if (ret)
             goto cleanup;
-        krb5int_buf_add(&buf, tok_val);
+        k5_buf_add(&buf, tok_val);
         free(tok_val);
         path_left = tok_end + 1;
     }
 
-    path = krb5int_buf_data(&buf);
+    path = k5_buf_data(&buf);
     if (path == NULL) {
         ret = ENOMEM;
         goto cleanup;
@@ -539,7 +539,7 @@ k5_expand_path_tokens_extra(krb5_context context, const char *path_in,
 
 cleanup:
     if (*path_out == NULL)
-        krb5int_free_buf(&buf);
+        k5_free_buf(&buf);
     free_extra_tokens(extra_tokens);
     return 0;
 }
diff --git a/src/lib/krb5/os/sendto_kdc.c b/src/lib/krb5/os/sendto_kdc.c
index 8488f6d..edc4a6e 100644
--- a/src/lib/krb5/os/sendto_kdc.c
+++ b/src/lib/krb5/os/sendto_kdc.c
@@ -193,27 +193,27 @@ krb5int_debug_fprint (const char *fmt, ...)
         case 'A':
             /* %A => addrinfo */
             ai = va_arg(args, struct addrinfo *);
-            krb5int_buf_init_dynamic(&buf);
+            k5_buf_init_dynamic(&buf);
             if (ai->ai_socktype == SOCK_DGRAM)
-                krb5int_buf_add(&buf, "dgram");
+                k5_buf_add(&buf, "dgram");
             else if (ai->ai_socktype == SOCK_STREAM)
-                krb5int_buf_add(&buf, "stream");
+                k5_buf_add(&buf, "stream");
             else
-                krb5int_buf_add_fmt(&buf, "socktype%d", ai->ai_socktype);
+                k5_buf_add_fmt(&buf, "socktype%d", ai->ai_socktype);
 
             if (0 != getnameinfo (ai->ai_addr, ai->ai_addrlen,
                                   addrbuf, sizeof (addrbuf),
                                   portbuf, sizeof (portbuf),
                                   NI_NUMERICHOST | NI_NUMERICSERV)) {
                 if (ai->ai_addr->sa_family == AF_UNSPEC)
-                    krb5int_buf_add(&buf, " AF_UNSPEC");
+                    k5_buf_add(&buf, " AF_UNSPEC");
                 else
-                    krb5int_buf_add_fmt(&buf, " af%d", ai->ai_addr->sa_family);
+                    k5_buf_add_fmt(&buf, " af%d", ai->ai_addr->sa_family);
             } else
-                krb5int_buf_add_fmt(&buf, " %s.%s", addrbuf, portbuf);
-            if (krb5int_buf_data(&buf))
-                putstr(krb5int_buf_data(&buf));
-            krb5int_free_buf(&buf);
+                k5_buf_add_fmt(&buf, " %s.%s", addrbuf, portbuf);
+            if (k5_buf_data(&buf))
+                putstr(k5_buf_data(&buf));
+            k5_free_buf(&buf);
             break;
         case 'D':
             /* %D => krb5_data * */
diff --git a/src/lib/krb5/os/trace.c b/src/lib/krb5/os/trace.c
index 8f9ba04..21fe105 100644
--- a/src/lib/krb5/os/trace.c
+++ b/src/lib/krb5/os/trace.c
@@ -64,15 +64,15 @@ buf_add_printable_len(struct k5buf *buf, const char *p, size_t len)
     size_t i;
 
     if (buf_is_printable(p, len)) {
-        krb5int_buf_add_len(buf, p, len);
+        k5_buf_add_len(buf, p, len);
     } else {
         for (i = 0; i < len; i++) {
             if (buf_is_printable(p + i, 1)) {
-                krb5int_buf_add_len(buf, p + i, 1);
+                k5_buf_add_len(buf, p + i, 1);
             } else {
                 snprintf(text, sizeof(text), "\\x%02x",
                          (unsigned)(p[i] & 0xff));
-                krb5int_buf_add_len(buf, text, 4);
+                k5_buf_add_len(buf, text, 4);
             }
         }
     }
@@ -145,11 +145,11 @@ trace_format(krb5_context context, const char *fmt, va_list ap)
     krb5_creds *creds;
     krb5_enctype *etypes, etype;
 
-    krb5int_buf_init_dynamic(&buf);
+    k5_buf_init_dynamic(&buf);
     while (TRUE) {
         /* Advance to the next word in braces. */
         len = strcspn(fmt, "{");
-        krb5int_buf_add_len(&buf, fmt, len);
+        k5_buf_add_len(&buf, fmt, len);
         if (fmt[len] == '\0')
             break;
         fmt += len + 1;
@@ -162,9 +162,9 @@ trace_format(krb5_context context, const char *fmt, va_list ap)
 
         /* Process the format word. */
         if (strcmp(tmpbuf, "int") == 0) {
-            krb5int_buf_add_fmt(&buf, "%d", va_arg(ap, int));
+            k5_buf_add_fmt(&buf, "%d", va_arg(ap, int));
         } else if (strcmp(tmpbuf, "long") == 0) {
-            krb5int_buf_add_fmt(&buf, "%ld", va_arg(ap, long));
+            k5_buf_add_fmt(&buf, "%ld", va_arg(ap, long));
         } else if (strcmp(tmpbuf, "str") == 0) {
             p = va_arg(ap, const char *);
             buf_add_printable(&buf, (p == NULL) ? "(null)" : p);
@@ -172,57 +172,57 @@ trace_format(krb5_context context, const char *fmt, va_list ap)
             len = va_arg(ap, size_t);
             p = va_arg(ap, const char *);
             if (p == NULL && len != 0)
-                krb5int_buf_add(&buf, "(null)");
+                k5_buf_add(&buf, "(null)");
             else
                 buf_add_printable_len(&buf, p, len);
         } else if (strcmp(tmpbuf, "hexlenstr") == 0) {
             len = va_arg(ap, size_t);
             p = va_arg(ap, const char *);
             if (p == NULL && len != 0)
-                krb5int_buf_add(&buf, "(null)");
+                k5_buf_add(&buf, "(null)");
             else {
                 for (i = 0; i < len; i++)
-                    krb5int_buf_add_fmt(&buf, "%02X", (unsigned char) p[i]);
+                    k5_buf_add_fmt(&buf, "%02X", (unsigned char)p[i]);
             }
         } else if (strcmp(tmpbuf, "hashlenstr") == 0) {
             len = va_arg(ap, size_t);
             p = va_arg(ap, const char *);
             if (p == NULL && len != 0)
-                krb5int_buf_add(&buf, "(null)");
+                k5_buf_add(&buf, "(null)");
             else {
                 str = hash_bytes(context, p, len);
                 if (str != NULL)
-                    krb5int_buf_add(&buf, str);
+                    k5_buf_add(&buf, str);
                 free(str);
             }
         } else if (strcmp(tmpbuf, "connstate") == 0) {
             cs = va_arg(ap, struct conn_state *);
             if (cs->socktype == SOCK_DGRAM)
-                krb5int_buf_add(&buf, "dgram");
+                k5_buf_add(&buf, "dgram");
             else if (cs->socktype == SOCK_STREAM)
-                krb5int_buf_add(&buf, "stream");
+                k5_buf_add(&buf, "stream");
             else
-                krb5int_buf_add_fmt(&buf, "socktype%d", cs->socktype);
+                k5_buf_add_fmt(&buf, "socktype%d", cs->socktype);
 
             if (getnameinfo((struct sockaddr *)&cs->addr, cs->addrlen,
                             addrbuf, sizeof(addrbuf), portbuf, sizeof(portbuf),
                             NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
                 if (cs->family == AF_UNSPEC)
-                    krb5int_buf_add(&buf, " AF_UNSPEC");
+                    k5_buf_add(&buf, " AF_UNSPEC");
                 else
-                    krb5int_buf_add_fmt(&buf, " af%d", cs->family);
+                    k5_buf_add_fmt(&buf, " af%d", cs->family);
             } else
-                krb5int_buf_add_fmt(&buf, " %s:%s", addrbuf, portbuf);
+                k5_buf_add_fmt(&buf, " %s:%s", addrbuf, portbuf);
         } else if (strcmp(tmpbuf, "data") == 0) {
             d = va_arg(ap, krb5_data *);
             if (d == NULL || (d->length != 0 && d->data == NULL))
-                krb5int_buf_add(&buf, "(null)");
+                k5_buf_add(&buf, "(null)");
             else
                 buf_add_printable_len(&buf, d->data, d->length);
         } else if (strcmp(tmpbuf, "hexdata") == 0) {
             d = va_arg(ap, krb5_data *);
             if (d == NULL)
-                krb5int_buf_add(&buf, "(null)");
+                k5_buf_add(&buf, "(null)");
             else
                 subfmt(context, &buf, "{hexlenstr}", d->length, d->data);
         } else if (strcmp(tmpbuf, "errno") == 0) {
@@ -234,17 +234,16 @@ trace_format(krb5_context context, const char *fmt, va_list ap)
 #endif
             if (p == NULL)
                 p = strerror(err);
-            krb5int_buf_add_fmt(&buf, "%d/%s", err, p);
+            k5_buf_add_fmt(&buf, "%d/%s", err, p);
         } else if (strcmp(tmpbuf, "kerr") == 0) {
             kerr = va_arg(ap, krb5_error_code);
             p = krb5_get_error_message(context, kerr);
-            krb5int_buf_add_fmt(&buf, "%ld/%s", (long) kerr,
-                                kerr ? p : "Success");
+            k5_buf_add_fmt(&buf, "%ld/%s", (long)kerr, kerr ? p : "Success");
             krb5_free_error_message(context, p);
         } else if (strcmp(tmpbuf, "keyblock") == 0) {
             keyblock = va_arg(ap, const krb5_keyblock *);
             if (keyblock == NULL)
-                krb5int_buf_add(&buf, "(null)");
+                k5_buf_add(&buf, "(null)");
             else {
                 subfmt(context, &buf, "{etype}/{hashlenstr}",
                        keyblock->enctype, keyblock->length,
@@ -253,7 +252,7 @@ trace_format(krb5_context context, const char *fmt, va_list ap)
         } else if (strcmp(tmpbuf, "key") == 0) {
             key = va_arg(ap, krb5_key);
             if (key == NULL)
-                krb5int_buf_add(&buf, "(null)");
+                k5_buf_add(&buf, "(null)");
             else
                 subfmt(context, &buf, "{keyblock}", &key->keyblock);
         } else if (strcmp(tmpbuf, "cksum") == 0) {
@@ -264,52 +263,52 @@ trace_format(krb5_context context, const char *fmt, va_list ap)
         } else if (strcmp(tmpbuf, "princ") == 0) {
             princ = va_arg(ap, krb5_principal);
             if (krb5_unparse_name(context, princ, &str) == 0) {
-                krb5int_buf_add(&buf, str);
+                k5_buf_add(&buf, str);
                 krb5_free_unparsed_name(context, str);
             }
         } else if (strcmp(tmpbuf, "ptype") == 0) {
             p = principal_type_string(va_arg(ap, krb5_int32));
-            krb5int_buf_add(&buf, p);
+            k5_buf_add(&buf, p);
         } else if (strcmp(tmpbuf, "patypes") == 0) {
             padata = va_arg(ap, krb5_pa_data **);
             if (padata == NULL || *padata == NULL)
-                krb5int_buf_add(&buf, "(empty)");
+                k5_buf_add(&buf, "(empty)");
             for (; padata != NULL && *padata != NULL; padata++) {
-                krb5int_buf_add_fmt(&buf, "%d", (int) (*padata)->pa_type);
+                k5_buf_add_fmt(&buf, "%d", (int)(*padata)->pa_type);
                 if (*(padata + 1) != NULL)
-                    krb5int_buf_add(&buf, ", ");
+                    k5_buf_add(&buf, ", ");
             }
         } else if (strcmp(tmpbuf, "etype") == 0) {
             etype = va_arg(ap, krb5_enctype);
             if (krb5_enctype_to_name(etype, TRUE, tmpbuf, sizeof(tmpbuf)) == 0)
-                krb5int_buf_add(&buf, tmpbuf);
+                k5_buf_add(&buf, tmpbuf);
             else
-                krb5int_buf_add_fmt(&buf, "%d", (int) etype);
+                k5_buf_add_fmt(&buf, "%d", (int)etype);
         } else if (strcmp(tmpbuf, "etypes") == 0) {
             etypes = va_arg(ap, krb5_enctype *);
             if (etypes == NULL || *etypes == 0)
-                krb5int_buf_add(&buf, "(empty)");
+                k5_buf_add(&buf, "(empty)");
             for (; etypes != NULL && *etypes != 0; etypes++) {
                 subfmt(context, &buf, "{etype}", *etypes);
                 if (*(etypes + 1) != 0)
-                    krb5int_buf_add(&buf, ", ");
+                    k5_buf_add(&buf, ", ");
             }
         } else if (strcmp(tmpbuf, "ccache") == 0) {
             ccache = va_arg(ap, krb5_ccache);
-            krb5int_buf_add(&buf, krb5_cc_get_type(context, ccache));
-            krb5int_buf_add(&buf, ":");
-            krb5int_buf_add(&buf, krb5_cc_get_name(context, ccache));
+            k5_buf_add(&buf, krb5_cc_get_type(context, ccache));
+            k5_buf_add(&buf, ":");
+            k5_buf_add(&buf, krb5_cc_get_name(context, ccache));
         } else if (strcmp(tmpbuf, "keytab") == 0) {
             keytab = va_arg(ap, krb5_keytab);
             if (krb5_kt_get_name(context, keytab, tmpbuf, sizeof(tmpbuf)) == 0)
-                krb5int_buf_add(&buf, tmpbuf);
+                k5_buf_add(&buf, tmpbuf);
         } else if (strcmp(tmpbuf, "creds") == 0) {
             creds = va_arg(ap, krb5_creds *);
             subfmt(context, &buf, "{princ} -> {princ}",
                    creds->client, creds->server);
         }
     }
-    return krb5int_buf_data(&buf);
+    return k5_buf_data(&buf);
 }
 
 /* Allows trace_format formatters to be represented in terms of other
@@ -323,7 +322,7 @@ subfmt(krb5_context context, struct k5buf *buf, const char *fmt, ...)
     va_start(ap, fmt);
     str = trace_format(context, fmt, ap);
     if (str != NULL)
-        krb5int_buf_add(buf, str);
+        k5_buf_add(buf, str);
     free(str);
     va_end(ap);
 }
diff --git a/src/lib/krb5/rcache/rc_dfl.c b/src/lib/krb5/rcache/rc_dfl.c
index 2981985..12e2a5d 100644
--- a/src/lib/krb5/rcache/rc_dfl.c
+++ b/src/lib/krb5/rcache/rc_dfl.c
@@ -670,11 +670,11 @@ krb5_rc_io_store(krb5_context context, struct dfl_data *t,
          */
 
         /* Format the extension value so we know its length. */
-        krb5int_buf_init_dynamic(&extbuf);
-        krb5int_buf_add_fmt(&extbuf, "HASH:%s %lu:%s %lu:%s", rep->msghash,
-                            (unsigned long) clientlen, rep->client,
-                            (unsigned long) serverlen, rep->server);
-        extstr = krb5int_buf_data(&extbuf);
+        k5_buf_init_dynamic(&extbuf);
+        k5_buf_add_fmt(&extbuf, "HASH:%s %lu:%s %lu:%s", rep->msghash,
+                       (unsigned long)clientlen, rep->client,
+                       (unsigned long)serverlen, rep->server);
+        extstr = k5_buf_data(&extbuf);
         if (!extstr)
             return KRB5_RC_MALLOC;
 
@@ -682,35 +682,35 @@ krb5_rc_io_store(krb5_context context, struct dfl_data *t,
          * Put the extension value into the server field of a
          * regular-format record, with an empty client field.
          */
-        krb5int_buf_init_dynamic(&buf);
+        k5_buf_init_dynamic(&buf);
         len = 1;
-        krb5int_buf_add_len(&buf, (char *) &len, sizeof(len));
-        krb5int_buf_add_len(&buf, "", 1);
+        k5_buf_add_len(&buf, (char *)&len, sizeof(len));
+        k5_buf_add_len(&buf, "", 1);
         len = strlen(extstr) + 1;
-        krb5int_buf_add_len(&buf, (char *) &len, sizeof(len));
-        krb5int_buf_add_len(&buf, extstr, len);
-        krb5int_buf_add_len(&buf, (char *) &rep->cusec, sizeof(rep->cusec));
-        krb5int_buf_add_len(&buf, (char *) &rep->ctime, sizeof(rep->ctime));
+        k5_buf_add_len(&buf, (char *)&len, sizeof(len));
+        k5_buf_add_len(&buf, extstr, len);
+        k5_buf_add_len(&buf, (char *)&rep->cusec, sizeof(rep->cusec));
+        k5_buf_add_len(&buf, (char *)&rep->ctime, sizeof(rep->ctime));
         free(extstr);
     } else  /* No extension record needed. */
-        krb5int_buf_init_dynamic(&buf);
+        k5_buf_init_dynamic(&buf);
 
     len = clientlen + 1;
-    krb5int_buf_add_len(&buf, (char *) &len, sizeof(len));
-    krb5int_buf_add_len(&buf, rep->client, len);
+    k5_buf_add_len(&buf, (char *)&len, sizeof(len));
+    k5_buf_add_len(&buf, rep->client, len);
     len = serverlen + 1;
-    krb5int_buf_add_len(&buf, (char *) &len, sizeof(len));
-    krb5int_buf_add_len(&buf, rep->server, len);
-    krb5int_buf_add_len(&buf, (char *) &rep->cusec, sizeof(rep->cusec));
-    krb5int_buf_add_len(&buf, (char *) &rep->ctime, sizeof(rep->ctime));
+    k5_buf_add_len(&buf, (char *)&len, sizeof(len));
+    k5_buf_add_len(&buf, rep->server, len);
+    k5_buf_add_len(&buf, (char *)&rep->cusec, sizeof(rep->cusec));
+    k5_buf_add_len(&buf, (char *)&rep->ctime, sizeof(rep->ctime));
 
-    bufptr = krb5int_buf_data(&buf);
-    buflen = krb5int_buf_len(&buf);
+    bufptr = k5_buf_data(&buf);
+    buflen = k5_buf_len(&buf);
     if (bufptr == NULL || buflen < 0)
         return KRB5_RC_MALLOC;
 
     ret = krb5_rc_io_write(context, &t->d, bufptr, buflen);
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
     return ret;
 }
 
diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal.c
index 7ce50b3..47ba5f0 100644
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal.c
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal.c
@@ -412,14 +412,14 @@ krb5_ldap_parse_principal_name(char *i_princ_name, char **o_princ_name)
         if (!o_princ_name)
             return ENOMEM;
     } else {
-        krb5int_buf_init_dynamic(&buf);
+        k5_buf_init_dynamic(&buf);
         for (p = i_princ_name; p < at_rlm_name; p++) {
             if (*p == '@')
-                krb5int_buf_add(&buf, "\\");
-            krb5int_buf_add_len(&buf, p, 1);
+                k5_buf_add(&buf, "\\");
+            k5_buf_add_len(&buf, p, 1);
         }
-        krb5int_buf_add(&buf, at_rlm_name);
-        *o_princ_name = krb5int_buf_data(&buf);
+        k5_buf_add(&buf, at_rlm_name);
+        *o_princ_name = k5_buf_data(&buf);
         if (!*o_princ_name)
             return ENOMEM;
     }
diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c
index 1e3d535..ad6b7fe 100644
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_realm.c
@@ -78,16 +78,16 @@ ldap_filter_correct (char *in)
     const char special[] = "*()\\ #\"+,;<>";
     struct k5buf buf;
 
-    krb5int_buf_init_dynamic(&buf);
+    k5_buf_init_dynamic(&buf);
     while (TRUE) {
         count = strcspn(in, special);
-        krb5int_buf_add_len(&buf, in, count);
+        k5_buf_add_len(&buf, in, count);
         in += count;
         if (*in == '\0')
             break;
-        krb5int_buf_add_fmt(&buf, "\\%2x", (unsigned char)*in++);
+        k5_buf_add_fmt(&buf, "\\%2x", (unsigned char)*in++);
     }
-    return krb5int_buf_data(&buf);
+    return k5_buf_data(&buf);
 }
 
 static int
diff --git a/src/plugins/preauth/pkinit/pkinit_crypto_nss.c b/src/plugins/preauth/pkinit/pkinit_crypto_nss.c
index 7f73fbd..b33ce74 100644
--- a/src/plugins/preauth/pkinit/pkinit_crypto_nss.c
+++ b/src/plugins/preauth/pkinit/pkinit_crypto_nss.c
@@ -2053,39 +2053,34 @@ reassemble_pkcs11_name(PLArenaPool *pool, pkinit_identity_opts *idopts)
     int n = 0;
     char *ret;
 
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add(&buf, "PKCS11:");
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add(&buf, "PKCS11:");
     n = 0;
     if (idopts->p11_module_name != NULL) {
-        krb5int_buf_add_fmt(&buf, "%smodule_name=%s",
-                            n++ ? "," : "",
-                            idopts->p11_module_name);
+        k5_buf_add_fmt(&buf, "%smodule_name=%s", n++ ? "," : "",
+                       idopts->p11_module_name);
     }
     if (idopts->token_label != NULL) {
-        krb5int_buf_add_fmt(&buf, "%stoken=%s",
-                            n++ ? "," : "",
-                            idopts->token_label);
+        k5_buf_add_fmt(&buf, "%stoken=%s", n++ ? "," : "",
+                       idopts->token_label);
     }
     if (idopts->cert_label != NULL) {
-        krb5int_buf_add_fmt(&buf, "%scertlabel=%s",
-                            n++ ? "," : "",
-                            idopts->cert_label);
+        k5_buf_add_fmt(&buf, "%scertlabel=%s", n++ ? "," : "",
+                       idopts->cert_label);
     }
     if (idopts->cert_id_string != NULL) {
-        krb5int_buf_add_fmt(&buf, "%scertid=%s",
-                            n++ ? "," : "",
-                            idopts->cert_id_string);
+        k5_buf_add_fmt(&buf, "%scertid=%s", n++ ? "," : "",
+                       idopts->cert_id_string);
     }
     if (idopts->slotid != PK_NOSLOT) {
-        krb5int_buf_add_fmt(&buf, "%sslotid=%ld",
-                            n++ ? "," : "",
-                            (long)idopts->slotid);
+        k5_buf_add_fmt(&buf, "%sslotid=%ld", n++ ? "," : "",
+                       (long)idopts->slotid);
     }
-    if (krb5int_buf_len(&buf) >= 0)
-        ret = PORT_ArenaStrdup(pool, krb5int_buf_data(&buf));
+    if (k5_buf_len(&buf) >= 0)
+        ret = PORT_ArenaStrdup(pool, k5_buf_data(&buf));
     else
         ret = NULL;
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
     return ret;
 }
 
diff --git a/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c b/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
index 17c37c6..0360736 100644
--- a/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
+++ b/src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
@@ -4491,39 +4491,34 @@ reassemble_pkcs11_name(pkinit_identity_opts *idopts)
     int n = 0;
     char *ret;
 
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add(&buf, "PKCS11:");
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add(&buf, "PKCS11:");
     n = 0;
     if (idopts->p11_module_name != NULL) {
-        krb5int_buf_add_fmt(&buf, "%smodule_name=%s",
-                            n++ ? "," : "",
-                            idopts->p11_module_name);
+        k5_buf_add_fmt(&buf, "%smodule_name=%s", n++ ? "," : "",
+                       idopts->p11_module_name);
     }
     if (idopts->token_label != NULL) {
-        krb5int_buf_add_fmt(&buf, "%stoken=%s",
-                            n++ ? "," : "",
-                            idopts->token_label);
+        k5_buf_add_fmt(&buf, "%stoken=%s", n++ ? "," : "",
+                       idopts->token_label);
     }
     if (idopts->cert_label != NULL) {
-        krb5int_buf_add_fmt(&buf, "%scertlabel=%s",
-                            n++ ? "," : "",
-                            idopts->cert_label);
+        k5_buf_add_fmt(&buf, "%scertlabel=%s", n++ ? "," : "",
+                       idopts->cert_label);
     }
     if (idopts->cert_id_string != NULL) {
-        krb5int_buf_add_fmt(&buf, "%scertid=%s",
-                            n++ ? "," : "",
-                            idopts->cert_id_string);
+        k5_buf_add_fmt(&buf, "%scertid=%s", n++ ? "," : "",
+                       idopts->cert_id_string);
     }
     if (idopts->slotid != PK_NOSLOT) {
-        krb5int_buf_add_fmt(&buf, "%sslotid=%ld",
-                            n++ ? "," : "",
-                            (long)idopts->slotid);
+        k5_buf_add_fmt(&buf, "%sslotid=%ld", n++ ? "," : "",
+                       (long)idopts->slotid);
     }
-    if (krb5int_buf_len(&buf) >= 0)
-        ret = strdup(krb5int_buf_data(&buf));
+    if (k5_buf_len(&buf) >= 0)
+        ret = strdup(k5_buf_data(&buf));
     else
         ret = NULL;
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
     return ret;
 }
 
diff --git a/src/util/gss-kernel-lib/t_kgss_user.c b/src/util/gss-kernel-lib/t_kgss_user.c
index 8e13b46..0af9aa6 100644
--- a/src/util/gss-kernel-lib/t_kgss_user.c
+++ b/src/util/gss-kernel-lib/t_kgss_user.c
@@ -138,7 +138,7 @@ start_child(int *to_child_out, int *from_child_out, pid_t *pid_out)
     *pid_out = pid;
 }
 
-#define WRITE(b, d) krb5int_buf_add_len(b, (char *)&d, sizeof(d))
+#define WRITE(b, d) k5_buf_add_len(b, (char *)&d, sizeof(d))
 
 /* Add the fields of lkey to bufp. */
 static void
@@ -146,7 +146,7 @@ add_lucid_key(struct k5buf *bufp, const gss_krb5_lucid_key_t *lkey)
 {
     WRITE(bufp, lkey->type);
     WRITE(bufp, lkey->length);
-    krb5int_buf_add_len(bufp, lkey->data, lkey->length);
+    k5_buf_add_len(bufp, lkey->data, lkey->length);
 }
 
 /* Using a machine-dependent format, marshal the fields of lctx into an
@@ -157,7 +157,7 @@ marshal_lucid_context(const gss_krb5_lucid_context_v1_t *lctx,
 {
     struct k5buf buf;
 
-    krb5int_buf_init_dynamic(&buf);
+    k5_buf_init_dynamic(&buf);
     WRITE(&buf, lctx->version);
     WRITE(&buf, lctx->initiate);
     WRITE(&buf, lctx->endtime);
@@ -175,9 +175,9 @@ marshal_lucid_context(const gss_krb5_lucid_context_v1_t *lctx,
             add_lucid_key(&buf, &lctx->cfx_kd.acceptor_subkey);
     } else
         abort();
-    assert(krb5int_buf_data(&buf) != NULL);
-    *data_out = (unsigned char *)krb5int_buf_data(&buf);
-    *len_out = krb5int_buf_len(&buf);
+    assert(k5_buf_data(&buf) != NULL);
+    *data_out = (unsigned char *)k5_buf_data(&buf);
+    *len_out = k5_buf_len(&buf);
 }
 
 /* Export ctx as a lucid context, marshal it, and write it to fd. */
diff --git a/src/util/support/json.c b/src/util/support/json.c
index e3edffd..c7f6fdd 100644
--- a/src/util/support/json.c
+++ b/src/util/support/json.c
@@ -575,22 +575,22 @@ encode_string(struct k5buf *buf, const char *str)
     size_t n;
     const char *p;
 
-    krb5int_buf_add(buf, "\"");
+    k5_buf_add(buf, "\"");
     while (*str != '\0') {
         n = strcspn(str, needs_quote);
-        krb5int_buf_add_len(buf, str, n);
+        k5_buf_add_len(buf, str, n);
         str += n;
         if (*str == '\0')
             break;
-        krb5int_buf_add(buf, "\\");
+        k5_buf_add(buf, "\\");
         p = strchr(quotemap_c, *str);
         if (p != NULL)
-            krb5int_buf_add_len(buf, quotemap_json + (p - quotemap_c), 1);
+            k5_buf_add_len(buf, quotemap_json + (p - quotemap_c), 1);
         else
-            krb5int_buf_add_fmt(buf, "u00%02X", (unsigned int)*str);
+            k5_buf_add_fmt(buf, "u00%02X", (unsigned int)*str);
         str++;
     }
-    krb5int_buf_add(buf, "\"");
+    k5_buf_add(buf, "\"");
 }
 
 struct obj_ctx {
@@ -609,9 +609,9 @@ encode_obj_entry(void *ctx, const char *key, k5_json_value value)
     if (j->first)
         j->first = 0;
     else
-        krb5int_buf_add(j->buf, ",");
+        k5_buf_add(j->buf, ",");
     encode_string(j->buf, key);
-    krb5int_buf_add(j->buf, ":");
+    k5_buf_add(j->buf, ":");
     j->ret = encode_value(j->buf, value);
 }
 
@@ -629,25 +629,25 @@ encode_value(struct k5buf *buf, k5_json_value val)
     type = k5_json_get_tid(val);
     switch (type) {
     case K5_JSON_TID_ARRAY:
-        krb5int_buf_add(buf, "[");
+        k5_buf_add(buf, "[");
         len = k5_json_array_length(val);
         for (i = 0; i < len; i++) {
             if (i != 0)
-                krb5int_buf_add(buf, ",");
+                k5_buf_add(buf, ",");
             ret = encode_value(buf, k5_json_array_get(val, i));
             if (ret)
                 return ret;
         }
-        krb5int_buf_add(buf, "]");
+        k5_buf_add(buf, "]");
         return 0;
 
     case K5_JSON_TID_OBJECT:
-        krb5int_buf_add(buf, "{");
+        k5_buf_add(buf, "{");
         ctx.buf = buf;
         ctx.ret = 0;
         ctx.first = 1;
         k5_json_object_iterate(val, encode_obj_entry, &ctx);
-        krb5int_buf_add(buf, "}");
+        k5_buf_add(buf, "}");
         return ctx.ret;
 
     case K5_JSON_TID_STRING:
@@ -655,15 +655,15 @@ encode_value(struct k5buf *buf, k5_json_value val)
         return 0;
 
     case K5_JSON_TID_NUMBER:
-        krb5int_buf_add_fmt(buf, "%lld", k5_json_number_value(val));
+        k5_buf_add_fmt(buf, "%lld", k5_json_number_value(val));
         return 0;
 
     case K5_JSON_TID_NULL:
-        krb5int_buf_add(buf, "null");
+        k5_buf_add(buf, "null");
         return 0;
 
     case K5_JSON_TID_BOOL:
-        krb5int_buf_add(buf, k5_json_bool_value(val) ? "true" : "false");
+        k5_buf_add(buf, k5_json_bool_value(val) ? "true" : "false");
         return 0;
 
     default:
@@ -678,13 +678,13 @@ k5_json_encode(k5_json_value val, char **json_out)
     int ret;
 
     *json_out = NULL;
-    krb5int_buf_init_dynamic(&buf);
+    k5_buf_init_dynamic(&buf);
     ret = encode_value(&buf, val);
     if (ret) {
-        krb5int_free_buf(&buf);
+        k5_free_buf(&buf);
         return ret;
     }
-    *json_out = krb5int_buf_data(&buf);
+    *json_out = k5_buf_data(&buf);
     return (*json_out == NULL) ? ENOMEM : 0;
 }
 
diff --git a/src/util/support/k5buf-int.h b/src/util/support/k5buf-int.h
index cc3c04c..6f2ec19 100644
--- a/src/util/support/k5buf-int.h
+++ b/src/util/support/k5buf-int.h
@@ -1,5 +1,5 @@
 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/* util/support/k5buf-int.h */
+/* util/support/k5buf-int.h - Internal declarations for string buffers */
 /*
  * Copyright 2008 Massachusetts Institute of Technology.
  * All Rights Reserved.
@@ -24,17 +24,16 @@
  * or implied warranty.
  */
 
-/* Internal declarations for the k5buf string buffer module */
-
 #ifndef K5BUF_INT_H
 #define K5BUF_INT_H
 
 #include "k5-platform.h"
 #include "k5-buf.h"
 
-/* The k5buf structure has funny field names to discourage callers
-   from violating the abstraction barrier.  Define less funny names
-   for them here. */
+/*
+ * The k5buf structure has funny field names to discourage callers from
+ * violating the abstraction barrier.  Define less funny names for them here.
+ */
 #define buftype xx_buftype
 #define data xx_data
 #define space xx_space
diff --git a/src/util/support/k5buf.c b/src/util/support/k5buf.c
index 5040ded..7d491ce 100644
--- a/src/util/support/k5buf.c
+++ b/src/util/support/k5buf.c
@@ -1,5 +1,6 @@
 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/* util/support/k5buf.c */
+/* util/support/k5buf.c - string buffer functions */
+
 /*
  * Copyright 2008 Massachusetts Institute of Technology.
  * All Rights Reserved.
@@ -24,11 +25,11 @@
  * or implied warranty.
  */
 
-/* Implement the k5buf string buffer module. */
-
-/* Can't include krb5.h here, or k5-int.h which includes it, because
-   krb5.h needs to be generated with error tables, after util/et,
-   which builds after this directory.  */
+/*
+ * Can't include krb5.h here, or k5-int.h which includes it, because krb5.h
+ * needs to be generated with error tables, after util/et, which builds after
+ * this directory.
+ */
 #include "k5buf-int.h"
 #include <assert.h>
 
@@ -43,10 +44,13 @@
  *   data[len] = '\0'
  */
 
-/* Make sure there is room for LEN more characters in BUF, in addition
-   to the null terminator and what's already in there.  Return true on
-   success.  On failure, set the error flag and return false. */
-static int ensure_space(struct k5buf *buf, size_t len)
+/*
+ * Make sure there is room for LEN more characters in BUF, in addition to the
+ * null terminator and what's already in there.  Return true on success.  On
+ * failure, set the error flag and return false.
+ */
+static int
+ensure_space(struct k5buf *buf, size_t len)
 {
     size_t new_space;
     char *new_data;
@@ -79,7 +83,8 @@ error_exit:
     return 0;
 }
 
-void krb5int_buf_init_fixed(struct k5buf *buf, char *data, size_t space)
+void
+k5_buf_init_fixed(struct k5buf *buf, char *data, size_t space)
 {
     assert(space > 0);
     buf->buftype = BUFTYPE_FIXED;
@@ -89,7 +94,8 @@ void krb5int_buf_init_fixed(struct k5buf *buf, char *data, size_t space)
     buf->data[0] = '\0';
 }
 
-void krb5int_buf_init_dynamic(struct k5buf *buf)
+void
+k5_buf_init_dynamic(struct k5buf *buf)
 {
     buf->buftype = BUFTYPE_DYNAMIC;
     buf->space = DYNAMIC_INITIAL_SIZE;
@@ -102,12 +108,14 @@ void krb5int_buf_init_dynamic(struct k5buf *buf)
     buf->data[0] = '\0';
 }
 
-void krb5int_buf_add(struct k5buf *buf, const char *data)
+void
+k5_buf_add(struct k5buf *buf, const char *data)
 {
-    krb5int_buf_add_len(buf, data, strlen(data));
+    k5_buf_add_len(buf, data, strlen(data));
 }
 
-void krb5int_buf_add_len(struct k5buf *buf, const char *data, size_t len)
+void
+k5_buf_add_len(struct k5buf *buf, const char *data, size_t len)
 {
     if (!ensure_space(buf, len))
         return;
@@ -116,7 +124,8 @@ void krb5int_buf_add_len(struct k5buf *buf, const char *data, size_t len)
     buf->data[buf->len] = '\0';
 }
 
-void krb5int_buf_add_fmt(struct k5buf *buf, const char *fmt, ...)
+void
+k5_buf_add_fmt(struct k5buf *buf, const char *fmt, ...)
 {
     va_list ap;
     int r;
@@ -164,8 +173,8 @@ void krb5int_buf_add_fmt(struct k5buf *buf, const char *fmt, ...)
         return;
     }
 
-    /* It's a pre-C99 snprintf implementation, or something else went
-       wrong.  Fall back to asprintf. */
+    /* It's a pre-C99 snprintf implementation, or something else went wrong.
+     * Fall back to asprintf. */
     va_start(ap, fmt);
     r = vasprintf(&tmp, fmt, ap);
     va_end(ap);
@@ -181,7 +190,8 @@ void krb5int_buf_add_fmt(struct k5buf *buf, const char *fmt, ...)
     free(tmp);
 }
 
-void krb5int_buf_truncate(struct k5buf *buf, size_t len)
+void
+k5_buf_truncate(struct k5buf *buf, size_t len)
 {
     if (buf->buftype == BUFTYPE_ERROR)
         return;
@@ -191,17 +201,20 @@ void krb5int_buf_truncate(struct k5buf *buf, size_t len)
 }
 
 
-char *krb5int_buf_data(struct k5buf *buf)
+char *
+k5_buf_data(struct k5buf *buf)
 {
     return (buf->buftype == BUFTYPE_ERROR) ? NULL : buf->data;
 }
 
-ssize_t krb5int_buf_len(struct k5buf *buf)
+ssize_t
+k5_buf_len(struct k5buf *buf)
 {
     return (buf->buftype == BUFTYPE_ERROR) ? -1 : (ssize_t) buf->len;
 }
 
-void krb5int_free_buf(struct k5buf *buf)
+void
+k5_free_buf(struct k5buf *buf)
 {
     if (buf->buftype == BUFTYPE_ERROR)
         return;
diff --git a/src/util/support/libkrb5support-fixed.exports b/src/util/support/libkrb5support-fixed.exports
index 41c8c6b..d6f881d 100644
--- a/src/util/support/libkrb5support-fixed.exports
+++ b/src/util/support/libkrb5support-fixed.exports
@@ -1,3 +1,12 @@
+k5_buf_init_fixed
+k5_buf_init_dynamic
+k5_buf_add
+k5_buf_add_len
+k5_buf_add_fmt
+k5_buf_truncate
+k5_buf_data
+k5_buf_len
+k5_free_buf
 k5_set_error
 k5_vset_error
 k5_set_error_fl
@@ -61,15 +70,6 @@ krb5int_mutex_free
 krb5int_mutex_lock
 krb5int_mutex_unlock
 krb5int_gmt_mktime
-krb5int_buf_init_fixed
-krb5int_buf_init_dynamic
-krb5int_buf_add
-krb5int_buf_add_len
-krb5int_buf_add_fmt
-krb5int_buf_truncate
-krb5int_buf_data
-krb5int_buf_len
-krb5int_free_buf
 krb5int_utf8cs_to_ucs2les
 krb5int_utf8s_to_ucs2les
 krb5int_ucs2lecs_to_utf8s
diff --git a/src/util/support/t_k5buf.c b/src/util/support/t_k5buf.c
index a6195fc..5e660d4 100644
--- a/src/util/support/t_k5buf.c
+++ b/src/util/support/t_k5buf.c
@@ -28,7 +28,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-static void fail_if(int condition, const char *name)
+static void
+fail_if(int condition, const char *name)
 {
     if (condition) {
         fprintf(stderr, "%s failed\n", name);
@@ -37,7 +38,8 @@ static void fail_if(int condition, const char *name)
 }
 
 /* Test the invariants of a buffer. */
-static void check_buf(struct k5buf *buf, const char *name)
+static void
+check_buf(struct k5buf *buf, const char *name)
 {
     fail_if(buf->buftype != BUFTYPE_FIXED && buf->buftype != BUFTYPE_DYNAMIC
             && buf->buftype != BUFTYPE_ERROR, name);
@@ -49,31 +51,33 @@ static void check_buf(struct k5buf *buf, const char *name)
     fail_if(buf->data[buf->len] != 0, name);
 }
 
-static void test_basic()
+static void
+test_basic()
 {
     struct k5buf buf;
     char storage[1024], *s;
     ssize_t len;
 
-    krb5int_buf_init_fixed(&buf, storage, sizeof(storage));
-    krb5int_buf_add(&buf, "Hello ");
-    krb5int_buf_add_len(&buf, "world", 5);
+    k5_buf_init_fixed(&buf, storage, sizeof(storage));
+    k5_buf_add(&buf, "Hello ");
+    k5_buf_add_len(&buf, "world", 5);
     check_buf(&buf, "basic fixed");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || strcmp(s, "Hello world") != 0 || len != 11, "basic fixed");
 
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add_len(&buf, "Hello", 5);
-    krb5int_buf_add(&buf, " world");
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add_len(&buf, "Hello", 5);
+    k5_buf_add(&buf, " world");
     check_buf(&buf, "basic dynamic");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || strcmp(s, "Hello world") != 0 || len != 11, "basic dynamic");
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
 }
 
-static void test_realloc()
+static void
+test_realloc()
 {
     struct k5buf buf;
     char data[1024], *s;
@@ -84,151 +88,156 @@ static void test_realloc()
         data[i] = 'a';
 
     /* Cause the buffer size to double from 128 to 256 bytes. */
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add_len(&buf, data, 10);
-    krb5int_buf_add_len(&buf, data, 128);
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add_len(&buf, data, 10);
+    k5_buf_add_len(&buf, data, 128);
     fail_if(buf.space != 256, "realloc 1");
     check_buf(&buf, "realloc 1");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || len != 138 || memcmp(s, data, len) != 0, "realloc 1");
 
     /* Cause the same buffer to double in size to 512 bytes. */
-    krb5int_buf_add_len(&buf, data, 128);
+    k5_buf_add_len(&buf, data, 128);
     fail_if(buf.space != 512, "realloc 2");
     check_buf(&buf, "realloc 2");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || len != 266 || memcmp(s, data, len) != 0, "realloc 2");
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
 
     /* Cause a buffer to increase from 128 to 512 bytes directly. */
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add_len(&buf, data, 10);
-    krb5int_buf_add_len(&buf, data, 256);
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add_len(&buf, data, 10);
+    k5_buf_add_len(&buf, data, 256);
     fail_if(buf.space != 512, "realloc 3");
     check_buf(&buf, "realloc 3");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || len != 266 || memcmp(s, data, len) != 0, "realloc 3");
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
 
     /* Cause a buffer to increase from 128 to 1024 bytes directly. */
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add_len(&buf, data, 10);
-    krb5int_buf_add_len(&buf, data, 512);
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add_len(&buf, data, 10);
+    k5_buf_add_len(&buf, data, 512);
     fail_if(buf.space != 1024, "realloc 4");
     check_buf(&buf, "realloc 4");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || len != 522 || memcmp(s, data, len) != 0, "realloc 4");
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
 
     /* Cause a reallocation to fail by exceeding SPACE_MAX. */
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add_len(&buf, data, 10);
-    krb5int_buf_add_len(&buf, NULL, SPACE_MAX);
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add_len(&buf, data, 10);
+    k5_buf_add_len(&buf, NULL, SPACE_MAX);
     check_buf(&buf, "realloc 5");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(buf.buftype != BUFTYPE_ERROR || s != NULL || len != -1,
             "realloc 5");
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
 
     /* Cause a reallocation to fail by integer overflow. */
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add_len(&buf, data, 100);
-    krb5int_buf_add_len(&buf, NULL, SPACE_MAX * 2);
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add_len(&buf, data, 100);
+    k5_buf_add_len(&buf, NULL, SPACE_MAX * 2);
     check_buf(&buf, "realloc 6");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(buf.buftype != BUFTYPE_ERROR || s != NULL || len != -1,
             "realloc 6");
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
 }
 
-static void test_overflow()
+static void
+test_overflow()
 {
     struct k5buf buf;
     char storage[10], *s;
     ssize_t len;
 
     /* Cause a fixed-sized buffer overflow. */
-    krb5int_buf_init_fixed(&buf, storage, sizeof(storage));
-    krb5int_buf_add(&buf, "12345");
-    krb5int_buf_add(&buf, "12345");
+    k5_buf_init_fixed(&buf, storage, sizeof(storage));
+    k5_buf_add(&buf, "12345");
+    k5_buf_add(&buf, "12345");
     check_buf(&buf, "overflow 1");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(buf.buftype != BUFTYPE_ERROR || s != NULL || len != -1,
             "overflow 1");
 
     /* Cause a fixed-sized buffer overflow with integer overflow. */
-    krb5int_buf_init_fixed(&buf, storage, sizeof(storage));
-    krb5int_buf_add(&buf, "12345");
-    krb5int_buf_add_len(&buf, NULL, SPACE_MAX * 2);
+    k5_buf_init_fixed(&buf, storage, sizeof(storage));
+    k5_buf_add(&buf, "12345");
+    k5_buf_add_len(&buf, NULL, SPACE_MAX * 2);
     check_buf(&buf, "overflow 2");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(buf.buftype != BUFTYPE_ERROR || s != NULL || len != -1,
             "overflow 2");
 }
 
-static void test_error()
+static void
+test_error()
 {
     struct k5buf buf;
     char storage[1];
 
     /* Cause an overflow and then perform actions afterwards. */
-    krb5int_buf_init_fixed(&buf, storage, sizeof(storage));
-    krb5int_buf_add(&buf, "1");
+    k5_buf_init_fixed(&buf, storage, sizeof(storage));
+    k5_buf_add(&buf, "1");
     fail_if(buf.buftype != BUFTYPE_ERROR, "error");
     check_buf(&buf, "error");
-    krb5int_buf_add(&buf, "test");
+    k5_buf_add(&buf, "test");
     check_buf(&buf, "error");
-    krb5int_buf_add_len(&buf, "test", 4);
+    k5_buf_add_len(&buf, "test", 4);
     check_buf(&buf, "error");
-    krb5int_buf_truncate(&buf, 3);
+    k5_buf_truncate(&buf, 3);
     check_buf(&buf, "error");
     fail_if(buf.buftype != BUFTYPE_ERROR, "error");
 }
 
-static void test_truncate()
+static void
+test_truncate()
 {
     struct k5buf buf;
     char *s;
     ssize_t len;
 
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add(&buf, "abcde");
-    krb5int_buf_add(&buf, "fghij");
-    krb5int_buf_truncate(&buf, 7);
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add(&buf, "abcde");
+    k5_buf_add(&buf, "fghij");
+    k5_buf_truncate(&buf, 7);
     check_buf(&buf, "truncate");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || len != 7 || strcmp(s, "abcdefg") != 0, "truncate");
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
 }
 
-static void test_binary()
+static void
+test_binary()
 {
     struct k5buf buf;
     char *s, data[] = { 'a', 0, 'b' };
     ssize_t len;
 
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add_len(&buf, data, 3);
-    krb5int_buf_add_len(&buf, data, 3);
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add_len(&buf, data, 3);
+    k5_buf_add_len(&buf, data, 3);
     check_buf(&buf, "binary");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || len != 6, "binary");
     fail_if(s[0] != 'a' || s[1] != 0 || s[2] != 'b', "binary");
     fail_if(s[3] != 'a' || s[4] != 0 || s[5] != 'b', "binary");
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
 }
 
-static void test_fmt()
+static void
+test_fmt()
 {
     struct k5buf buf;
     char *s, storage[10], data[1024];
@@ -240,41 +249,42 @@ static void test_fmt()
     data[i] = '\0';
 
     /* Format some text into a non-empty fixed buffer. */
-    krb5int_buf_init_fixed(&buf, storage, sizeof(storage));
-    krb5int_buf_add(&buf, "foo");
-    krb5int_buf_add_fmt(&buf, " %d ", 3);
+    k5_buf_init_fixed(&buf, storage, sizeof(storage));
+    k5_buf_add(&buf, "foo");
+    k5_buf_add_fmt(&buf, " %d ", 3);
     check_buf(&buf, "fmt 1");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || len != 6 || strcmp(s, "foo 3 ") != 0, "fmt 1");
 
     /* Overflow the same buffer with formatted text. */
-    krb5int_buf_add_fmt(&buf, "%d%d%d%d", 1, 2, 3, 4);
+    k5_buf_add_fmt(&buf, "%d%d%d%d", 1, 2, 3, 4);
     check_buf(&buf, "fmt 2");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(buf.buftype != BUFTYPE_ERROR || s != NULL || len != -1, "fmt 2");
 
     /* Format some text into a non-empty dynamic buffer. */
-    krb5int_buf_init_dynamic(&buf);
-    krb5int_buf_add(&buf, "foo");
-    krb5int_buf_add_fmt(&buf, " %d ", 3);
+    k5_buf_init_dynamic(&buf);
+    k5_buf_add(&buf, "foo");
+    k5_buf_add_fmt(&buf, " %d ", 3);
     check_buf(&buf, "fmt 3");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || len != 6 || strcmp(s, "foo 3 ") != 0, "fmt 3");
 
     /* Format more text into the same buffer, causing a big resize. */
-    krb5int_buf_add_fmt(&buf, "%s", data);
+    k5_buf_add_fmt(&buf, "%s", data);
     check_buf(&buf, "fmt 4");
     fail_if(buf.space != 2048, "fmt 4");
-    s = krb5int_buf_data(&buf);
-    len = krb5int_buf_len(&buf);
+    s = k5_buf_data(&buf);
+    len = k5_buf_len(&buf);
     fail_if(!s || len != 1029 || strcmp(s + 6, data) != 0, "fmt 4");
-    krb5int_free_buf(&buf);
+    k5_free_buf(&buf);
 }
 
-int main()
+int
+main()
 {
     test_basic();
     test_realloc();


More information about the cvs-krb5 mailing list