git.samba.org
/
metze
/
samba
/
wip.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9cddf89
)
s4:dsdb: fix samdb_result_logon_hours() and don't hardcode units_per_week
author
Stefan Metzmacher
<metze@samba.org>
Wed, 12 May 2010 15:34:02 +0000
(17:34 +0200)
committer
Stefan Metzmacher
<metze@samba.org>
Wed, 12 May 2010 17:30:57 +0000
(19:30 +0200)
metze
source4/dsdb/common/util.c
patch
|
blob
|
history
diff --git
a/source4/dsdb/common/util.c
b/source4/dsdb/common/util.c
index b9bff91eb84aaaaa3110b7a59d172ddcb327a9d0..63870278ceb3f75029723458d6dac6c0bc71c085 100644
(file)
--- 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;
struct samr_LogonHours samdb_result_logon_hours(TALLOC_CTX *mem_ctx, struct ldb_message *msg, const char *attr)
{
struct samr_LogonHours hours;
-
const in
t units_per_week = 168;
+
size_
t units_per_week = 168;
const struct ldb_val *val = ldb_msg_find_ldb_val(msg, attr);
const struct ldb_val *val = ldb_msg_find_ldb_val(msg, attr);
+
ZERO_STRUCT(hours);
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;
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) {
if (val) {
- memcpy(hours.bits, val->data,
MIN(val->length, units_per_week)
);
+ memcpy(hours.bits, val->data,
val->length
);
}
}
+
return hours;
}
return hours;
}