summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorC. Davis <cd.rattan@gmail.com>2012-08-19 20:09:53 -0700
committerMichael Adam <obnox@samba.org>2013-04-29 13:08:22 +0200
commit68d4e8dfc75fa788eae44e7f23ec866450792837 (patch)
tree29730b0caebc668c21a718c6ff88310ce6ab89bd /source3/utils
parent8508b411b2ff69f59aa133ebd97e489d7c6c1626 (diff)
downloadsamba-68d4e8dfc75fa788eae44e7f23ec866450792837.tar.gz
samba-68d4e8dfc75fa788eae44e7f23ec866450792837.tar.bz2
samba-68d4e8dfc75fa788eae44e7f23ec866450792837.zip
regedit: Mark string values if they contain unprintable chars.
Also, edit the values in bin mode to avoid screen glitches. Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/utils')
-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 {