diff options
author | C. Davis <cd.rattan@gmail.com> | 2012-08-19 20:09:53 -0700 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-04-29 13:08:22 +0200 |
commit | 68d4e8dfc75fa788eae44e7f23ec866450792837 (patch) | |
tree | 29730b0caebc668c21a718c6ff88310ce6ab89bd /source3/utils/regedit_valuelist.c | |
parent | 8508b411b2ff69f59aa133ebd97e489d7c6c1626 (diff) | |
download | samba-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/regedit_valuelist.c')
-rw-r--r-- | source3/utils/regedit_valuelist.c | 31 |
1 files changed, 29 insertions, 2 deletions
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; } |