diff options
Diffstat (limited to 'src/util/string_utils.c')
-rw-r--r-- | src/util/string_utils.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util/string_utils.c b/src/util/string_utils.c index a39b950e8..71b2a0920 100644 --- a/src/util/string_utils.c +++ b/src/util/string_utils.c @@ -83,3 +83,28 @@ char * sss_reverse_replace_space(TALLOC_CTX *mem_ctx, return replace_char(mem_ctx, orig_name, subst, ' '); } + +errno_t guid_blob_to_string_buf(const uint8_t *blob, char *str_buf, + size_t buf_size) +{ + int ret; + + if (blob == NULL || str_buf == NULL || buf_size < GUID_STR_BUF_SIZE) { + DEBUG(SSSDBG_CRIT_FAILURE, "Buffer too small.\n"); + return EINVAL; + } + + ret = snprintf(str_buf, buf_size, + "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", + blob[3], blob[2], blob[1], blob[0], + blob[5], blob[4], + blob[7], blob[6], + blob[8], blob[9], + blob[10], blob[11],blob[12], blob[13],blob[14], blob[15]);; + if (ret != (GUID_STR_BUF_SIZE -1)) { + DEBUG(SSSDBG_CRIT_FAILURE, "snprintf failed.\n"); + return EIO; + } + + return EOK; +} |