diff options
author | Greg Hudson <ghudson@mit.edu> | 2023-03-13 17:42:50 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2023-03-24 14:45:58 -0400 |
commit | fc1ad91f68a06dfc9b082897120985d45438fa9f (patch) | |
tree | 21762c8bdeef858858cbf43946e5ae4c78810c54 /src/lib/gssapi | |
parent | ceb0d82f0a9f69615ca4f5ff3bbf92af17f610ac (diff) | |
download | krb5-fc1ad91f68a06dfc9b082897120985d45438fa9f.zip krb5-fc1ad91f68a06dfc9b082897120985d45438fa9f.tar.gz krb5-fc1ad91f68a06dfc9b082897120985d45438fa9f.tar.bz2 |
Make k5buf more flexible for binary data
Remove the invariant that buf.data is always zero-terminated, to allow
marshalling of binary data into precisely allocated fixed regions.
Add k5_buf_cstring() to zero-terminate the buffer and retrieve the
data pointer. Adjust all callers that build C strings appropriately.
Add a k5_buf_add_byte() convenience wrapper alongside the integer
marshalling wrappers. Change k5_buf_init_fixed() to accept a void
pointer so it can more conveniently be used with uint8_t arrays.
Diffstat (limited to 'src/lib/gssapi')
-rw-r--r-- | src/lib/gssapi/spnego/negoex_util.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/gssapi/spnego/negoex_util.c b/src/lib/gssapi/spnego/negoex_util.c index 99580fd..edc5462 100644 --- a/src/lib/gssapi/spnego/negoex_util.c +++ b/src/lib/gssapi/spnego/negoex_util.c @@ -157,7 +157,7 @@ guid_to_string(const uint8_t guid[GUID_LENGTH]) k5_buf_init_dynamic(&buf); add_guid(&buf, guid); - return buf.data; + return k5_buf_cstring(&buf); } /* Check that the described vector lies within the message, and return a @@ -188,7 +188,7 @@ trace_received_message(spnego_gss_ctx_id_t ctx, if (i + 1 < msg->u.n.nschemes) k5_buf_add(&buf, " "); } - info = buf.data; + info = k5_buf_cstring(&buf); } else if (msg->type == INITIATOR_META_DATA || msg->type == ACCEPTOR_META_DATA || msg->type == CHALLENGE || msg->type == AP_REQUEST) { @@ -613,7 +613,8 @@ negoex_add_nego_message(spnego_gss_ctx_id_t ctx, enum message_type type, if (buf.len > 0) { k5_buf_truncate(&buf, buf.len - 1); - TRACE_NEGOEX_OUTGOING(ctx->kctx, seqnum, typestr(type), buf.data); + TRACE_NEGOEX_OUTGOING(ctx->kctx, seqnum, typestr(type), + k5_buf_cstring(&buf)); k5_buf_free(&buf); } } |