summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/utils/regedit_dialog.c2
-rw-r--r--source3/utils/regedit_valuelist.c31
-rw-r--r--source3/utils/regedit_valuelist.h1
3 files changed, 31 insertions, 3 deletions
diff --git a/source3/utils/regedit_dialog.c b/source3/utils/regedit_dialog.c
index ddb6819940..c3dd19899b 100644
--- a/source3/utils/regedit_dialog.c
+++ b/source3/utils/regedit_dialog.c
@@ -1056,7 +1056,7 @@ WERROR dialog_edit_value(TALLOC_CTX *ctx, struct registry_key *key,
talloc_set_destructor(edit, edit_dialog_free);
edit->mode = type;
- if (force_binary) {
+ if (force_binary || (vitem && vitem->unprintable)) {
edit->mode = REG_BINARY;
}
diff --git a/source3/utils/regedit_valuelist.c b/source3/utils/regedit_valuelist.c
index e5c3822b55..4d21be5416 100644
--- a/source3/utils/regedit_valuelist.c
+++ b/source3/utils/regedit_valuelist.c
@@ -154,6 +154,19 @@ void value_list_show(struct value_list *vl)
post_menu(vl->menu);
}
+static bool string_is_printable(const char *s)
+{
+ const char *p;
+
+ for (p = s; *p; ++p) {
+ if (!isprint(*p)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
static WERROR append_data_summary(struct value_item *vitem)
{
char *tmp;
@@ -176,7 +189,14 @@ static WERROR append_data_summary(struct value_item *vitem)
if (!pull_reg_sz(vitem, &vitem->data, &s)) {
break;
}
- tmp = talloc_asprintf_append(vitem->value_desc, "(\"%s\")", s);
+ vitem->unprintable = !string_is_printable(s);
+ if (vitem->unprintable) {
+ tmp = talloc_asprintf_append(vitem->value_desc,
+ "(unprintable)");
+ } else {
+ tmp = talloc_asprintf_append(vitem->value_desc,
+ "(\"%s\")", s);
+ }
break;
}
case REG_MULTI_SZ: {
@@ -188,7 +208,14 @@ static WERROR append_data_summary(struct value_item *vitem)
}
tmp = vitem->value_desc;
for (i = 0; a[i] != NULL; ++i) {
- tmp = talloc_asprintf_append(tmp, "\"%s\" ", a[i]);
+ if (!string_is_printable(a[i])) {
+ tmp = talloc_asprintf_append(tmp,
+ "(unprintable)");
+ vitem->unprintable = true;
+ } else {
+ tmp = talloc_asprintf_append(tmp, "\"%s\" ",
+ a[i]);
+ }
if (tmp == NULL) {
return WERR_NOMEM;
}
diff --git a/source3/utils/regedit_valuelist.h b/source3/utils/regedit_valuelist.h
index 2923e98964..d01db51be2 100644
--- a/source3/utils/regedit_valuelist.h
+++ b/source3/utils/regedit_valuelist.h
@@ -32,6 +32,7 @@ struct value_item {
DATA_BLOB data;
const char *value_name;
char *value_desc;
+ bool unprintable;
};
struct value_list {