summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-05-12 17:34:02 +0200
committerStefan Metzmacher <metze@samba.org>2010-05-13 19:12:42 +0200
commit11730520a742df0f584a9a25762756763517dc4d (patch)
treea3fd48fdee5bd86bf637cbc6b58641eef686b797 /source4/dsdb
parent9ad9fd5b7120b4fe1bc4296795b5e007a85d1387 (diff)
downloadsamba-11730520a742df0f584a9a25762756763517dc4d.tar.gz
samba-11730520a742df0f584a9a25762756763517dc4d.tar.bz2
samba-11730520a742df0f584a9a25762756763517dc4d.zip
s4:dsdb: fix samdb_result_logon_hours() and don't hardcode units_per_week
metze
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/common/util.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index b9bff91eb8..63870278ce 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -630,18 +630,25 @@ NTSTATUS samdb_result_passwords(TALLOC_CTX *mem_ctx, struct loadparm_context *lp
struct samr_LogonHours samdb_result_logon_hours(TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char *attr)
{
struct samr_LogonHours hours;
- const int units_per_week = 168;
+ size_t units_per_week = 168;
const struct ldb_val *val = ldb_msg_find_ldb_val(msg, attr);
+
ZERO_STRUCT(hours);
- hours.bits = talloc_array(mem_ctx, uint8_t, units_per_week);
+
+ if (val) {
+ units_per_week = val->length * 8;
+ }
+
+ hours.bits = talloc_array(mem_ctx, uint8_t, units_per_week/8);
if (!hours.bits) {
return hours;
}
hours.units_per_week = units_per_week;
- memset(hours.bits, 0xFF, units_per_week);
+ memset(hours.bits, 0xFF, units_per_week/8);
if (val) {
- memcpy(hours.bits, val->data, MIN(val->length, units_per_week));
+ memcpy(hours.bits, val->data, val->length);
}
+
return hours;
}