From 00934d4c2fd449493ad52127616445673f0de5b5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Matthias=20Dieter=20Walln=C3=B6fer?= Date: Mon, 15 Mar 2010 11:51:42 +0100 Subject: [PATCH] s4:registry - fix up the output of hexadecimal values Use a fixed-length representation to avoid platform-specific issues. --- source4/lib/registry/ldb.c | 4 ++-- source4/lib/registry/util.c | 16 ++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 5c52cb238f1..6676193ef4d 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -225,7 +225,7 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, if (data.length == sizeof(uint32_t)) { char *conv_str; - conv_str = talloc_asprintf(msg, "0x%x", IVAL(data.data, 0)); + conv_str = talloc_asprintf(msg, "0x%8.8x", IVAL(data.data, 0)); if (conv_str == NULL) { talloc_free(msg); return NULL; @@ -263,7 +263,7 @@ static struct ldb_message *reg_ldb_pack_value(struct ldb_context *ctx, if (data.length == sizeof(uint64_t)) { char *conv_str; - conv_str = talloc_asprintf(msg, "0x%llx", BVAL(data.data, 0)); + conv_str = talloc_asprintf(msg, "0x%16.16llx", BVAL(data.data, 0)); if (conv_str == NULL) { talloc_free(msg); return NULL; diff --git a/source4/lib/registry/util.c b/source4/lib/registry/util.c index c7f4c0844ec..5b4c41f7526 100644 --- a/source4/lib/registry/util.c +++ b/source4/lib/registry/util.c @@ -86,22 +86,14 @@ _PUBLIC_ char *reg_val_data_string(TALLOC_CTX *mem_ctx, break; case REG_DWORD: if (data.length == sizeof(uint32_t)) { - if (IVAL(data.data, 0) == 0) { - ret = talloc_strdup(mem_ctx, "0"); - } else { - ret = talloc_asprintf(mem_ctx, "0x%x", - IVAL(data.data, 0)); - } + ret = talloc_asprintf(mem_ctx, "0x%8.8x", + IVAL(data.data, 0)); } break; case REG_QWORD: if (data.length == sizeof(uint64_t)) { - if (BVAL(data.data, 0) == 0) { - ret = talloc_strdup(mem_ctx, "0"); - } else { - ret = talloc_asprintf(mem_ctx, "0x%llx", - BVAL(data.data, 0)); - } + ret = talloc_asprintf(mem_ctx, "0x%16.16llx", + BVAL(data.data, 0)); } break; case REG_NONE: -- 2.34.1