summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2011-09-06 09:24:10 +0200
committerMichael Adam <obnox@samba.org>2011-10-01 23:51:05 +0200
commitb9da4235566ffdd649d7b4a6ca05cecd02cfbd20 (patch)
tree2d313d3b8bab6efb079f3eef9bcb3e9a67ae2847 /source3/registry
parent595cc42a46f5dfbac5c17a403fb1f82769f26ff2 (diff)
downloadsamba-b9da4235566ffdd649d7b4a6ca05cecd02cfbd20.tar.gz
samba-b9da4235566ffdd649d7b4a6ca05cecd02cfbd20.tar.bz2
samba-b9da4235566ffdd649d7b4a6ca05cecd02cfbd20.zip
s3:registry: reg_format: handle unterminated REG_SZ blobs
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_format.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/source3/registry/reg_format.c b/source3/registry/reg_format.c
index 658076c5cf..77a27fcc0a 100644
--- a/source3/registry/reg_format.c
+++ b/source3/registry/reg_format.c
@@ -326,6 +326,12 @@ done:
return ret;
}
+static bool is_zero_terminated_ucs2(const uint8_t* data, size_t len) {
+ const size_t idx = len/sizeof(smb_ucs2_t);
+ const smb_ucs2_t *str = (const smb_ucs2_t*)data;
+ return (idx > 0) && (str[idx] == 0);
+}
+
int reg_format_value(struct reg_format* f, const char* name, uint32_t type,
const uint8_t* data, size_t len)
{
@@ -334,7 +340,9 @@ int reg_format_value(struct reg_format* f, const char* name, uint32_t type,
switch (type) {
case REG_SZ:
- if (!(f->flags & REG_FMT_HEX_SZ)) {
+ if (!(f->flags & REG_FMT_HEX_SZ)
+ && is_zero_terminated_ucs2(data, len))
+ {
char* str = NULL;
size_t dlen;
if (pull_ucs2_talloc(mem_ctx, &str, (const smb_ucs2_t*)data, &dlen)) {