Commit ff3bb71e authored by Jelmer Vernooij's avatar Jelmer Vernooij

Merge tag 'upstream/1.1.26'

Upstream version 1.1.26

# gpg: Signature made Fri 26 Feb 2016 03:18:37 UTC using RSA key ID 04D1E9F8
# gpg: Good signature from "Jelmer Vernooij <jelmer@jelmer.uk>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@samba.org>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@apache.org>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@debian.org>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@ubuntu.com>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@vernstok.nl>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@jelmer.co.uk>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jelmer@openchange.org>" [ultimate]
# gpg:                 aka "Jelmer Vernooij <jrvernooij@tigris.org>" [ultimate]
parents 07c956bc 3d57990b
This diff is collapsed.
This diff is collapsed.
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
pyldb_Dn_FromDn: PyObject *(struct ldb_dn *)
pyldb_Object_AsDn: bool (TALLOC_CTX *, PyObject *, struct ldb_context *, struct ldb_dn **)
# encoding: utf-8
# Thomas Nagy, 2008-2010 (ita)
"""
Execute the tasks with gcc -MD, read the dependencies from the .d file
and prepare the dependency calculation for the next run
"""
import os, re, threading
import Task, Logs, Utils, preproc
from TaskGen import before, after, feature
lock = threading.Lock()
preprocessor_flag = '-MD'
@feature('c', 'cc')
@before('apply_core')
def add_mmd_cc(self):
if self.env.get_flat('CCFLAGS').find(preprocessor_flag) < 0:
self.env.append_value('CCFLAGS', preprocessor_flag)
@feature('cxx')
@before('apply_core')
def add_mmd_cxx(self):
if self.env.get_flat('CXXFLAGS').find(preprocessor_flag) < 0:
self.env.append_value('CXXFLAGS', preprocessor_flag)
def scan(self):
"the scanner does not do anything initially"
nodes = self.generator.bld.node_deps.get(self.unique_id(), [])
names = []
return (nodes, names)
re_o = re.compile("\.o$")
re_src = re.compile("^(\.\.)[\\/](.*)$")
def post_run(self):
# The following code is executed by threads, it is not safe, so a lock is needed...
if getattr(self, 'cached', None):
return Task.Task.post_run(self)
name = self.outputs[0].abspath(self.env)
name = re_o.sub('.d', name)
txt = Utils.readf(name)
#os.unlink(name)
txt = txt.replace('\\\n', '')
lst = txt.strip().split(':')
val = ":".join(lst[1:])
val = val.split()
nodes = []
bld = self.generator.bld
f = re.compile("^("+self.env.variant()+"|\.\.)[\\/](.*)$")
for x in val:
if os.path.isabs(x):
if not preproc.go_absolute:
continue
lock.acquire()
try:
node = bld.root.find_resource(x)
finally:
lock.release()
else:
g = re.search(re_src, x)
if g:
x = g.group(2)
lock.acquire()
try:
node = bld.bldnode.parent.find_resource(x)
finally:
lock.release()
else:
g = re.search(f, x)
if g:
x = g.group(2)
lock.acquire()
try:
node = bld.srcnode.find_resource(x)
finally:
lock.release()
if id(node) == id(self.inputs[0]):
# ignore the source file, it is already in the dependencies
# this way, successful config tests may be retrieved from the cache
continue
if not node:
raise ValueError('could not find %r for %r' % (x, self))
else:
nodes.append(node)
Logs.debug('deps: real scanner for %s returned %s' % (str(self), str(nodes)))
bld.node_deps[self.unique_id()] = nodes
bld.raw_deps[self.unique_id()] = []
try:
del self.cache_sig
except:
pass
Task.Task.post_run(self)
import Constants, Utils
def sig_implicit_deps(self):
try:
return Task.Task.sig_implicit_deps(self)
except Utils.WafError:
return Constants.SIG_NIL
for name in 'cc cxx'.split():
try:
cls = Task.TaskBase.classes[name]
except KeyError:
pass
else:
cls.post_run = post_run
cls.scan = scan
cls.sig_implicit_deps = sig_implicit_deps
......@@ -97,7 +97,18 @@ def SAMBA_PYTHON(bld, name,
# when we support static python modules we'll need to gather
# the list from all the SAMBA_PYTHON() targets
if init_function_sentinel is not None:
cflags += '-DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinel
cflags += ' -DSTATIC_LIBPYTHON_MODULES=%s' % init_function_sentinel
# From https://docs.python.org/2/c-api/arg.html:
# Starting with Python 2.5 the type of the length argument to
# PyArg_ParseTuple(), PyArg_ParseTupleAndKeywords() and PyArg_Parse()
# can be controlled by defining the macro PY_SSIZE_T_CLEAN before
# including Python.h. If the macro is defined, length is a Py_ssize_t
# rather than an int.
# Because <Python.h> if often included before includes.h/config.h
# This must be in the -D compiler options
cflags += ' -DPY_SSIZE_T_CLEAN=1'
source = bld.EXPAND_VARIABLES(source, vars=vars)
......
......@@ -106,6 +106,7 @@ def SAMBA_LIBRARY(bld, libname, source,
includes='',
public_headers=None,
public_headers_install=True,
private_headers=None,
header_path=None,
pc_files=None,
vnum=None,
......@@ -145,8 +146,12 @@ def SAMBA_LIBRARY(bld, libname, source,
if pyembed and bld.env['IS_EXTRA_PYTHON']:
public_headers = pc_files = None
if private_library and public_headers:
raise Utils.WafError("private library '%s' must not have public header files" %
libname)
if LIB_MUST_BE_PRIVATE(bld, libname):
private_library=True
private_library = True
if not enabled:
SET_TARGET_TYPE(bld, libname, 'DISABLED')
......@@ -187,6 +192,7 @@ def SAMBA_LIBRARY(bld, libname, source,
includes = includes,
public_headers = public_headers,
public_headers_install = public_headers_install,
private_headers= private_headers,
header_path = header_path,
cflags = cflags,
group = subsystem_group,
......@@ -337,6 +343,7 @@ def SAMBA_BINARY(bld, binname, source,
deps='',
includes='',
public_headers=None,
private_headers=None,
header_path=None,
modules=None,
ldflags=None,
......@@ -539,6 +546,7 @@ def SAMBA_SUBSYSTEM(bld, modname, source,
includes='',
public_headers=None,
public_headers_install=True,
private_headers=None,
header_path=None,
cflags='',
cflags_end=None,
......@@ -631,6 +639,7 @@ def SAMBA_GENERATOR(bld, name, rule, source='', target='',
group='generators', enabled=True,
public_headers=None,
public_headers_install=True,
private_headers=None,
header_path=None,
vars=None,
dep_vars=[],
......
......@@ -229,6 +229,11 @@ def configure(conf):
# older gcc versions (< 4.4) does not work with gccdeps, so we have to see if the .d file is generated
if Options.options.enable_gccdeps:
# stale file removal - the configuration may pick up the old .pyc file
p = os.path.join(conf.srcdir, 'buildtools/wafsamba/gccdeps.pyc')
if os.path.exists(p):
os.remove(p)
from TaskGen import feature, after
@feature('testd')
@after('apply_core')
......
......@@ -367,6 +367,26 @@ char *ldb_control_to_string(TALLOC_CTX *mem_ctx, const struct ldb_control *contr
talloc_free(cookie);
return res;
}
if (strcmp(control->oid, LDB_CONTROL_DIRSYNC_EX_OID) == 0) {
char *cookie;
struct ldb_dirsync_control *rep_control = talloc_get_type(control->data,
struct ldb_dirsync_control);
cookie = ldb_base64_encode(mem_ctx, rep_control->cookie,
rep_control->cookie_len);
if (cookie == NULL) {
return NULL;
}
res = talloc_asprintf(mem_ctx, "%s:%d:%d:%d:%s",
LDB_CONTROL_DIRSYNC_EX_NAME,
control->critical,
rep_control->flags,
rep_control->max_attributes,
cookie);
talloc_free(cookie);
return res;
}
if (strcmp(control->oid, LDB_CONTROL_VERIFY_NAME_OID) == 0) {
struct ldb_verify_name_control *rep_control = talloc_get_type(control->data, struct ldb_verify_name_control);
......@@ -525,6 +545,51 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
return ctrl;
}
if (LDB_CONTROL_CMP(control_strings, LDB_CONTROL_DIRSYNC_EX_NAME) == 0) {
struct ldb_dirsync_control *control;
const char *p;
char cookie[1024];
int crit, max_attrs, ret;
uint32_t flags;
cookie[0] = '\0';
p = &(control_strings[sizeof(LDB_CONTROL_DIRSYNC_EX_NAME)]);
ret = sscanf(p, "%d:%u:%d:%1023[^$]", &crit, &flags, &max_attrs, cookie);
if ((ret < 3) || (crit < 0) || (crit > 1) || (max_attrs < 0)) {
error_string = talloc_asprintf(mem_ctx, "invalid %s control syntax\n",
LDB_CONTROL_DIRSYNC_EX_NAME);
error_string = talloc_asprintf_append(error_string, " syntax: crit(b):flags(n):max_attrs(n)[:cookie(o)]\n");
error_string = talloc_asprintf_append(error_string, " note: b = boolean, n = number, o = b64 binary blob");
ldb_set_errstring(ldb, error_string);
talloc_free(error_string);
talloc_free(ctrl);
return NULL;
}
/* w2k3 seems to ignore the parameter,
* but w2k sends a wrong cookie when this value is to small
* this would cause looping forever, while getting
* the same data and same cookie forever
*/
if (max_attrs == 0) max_attrs = 0x0FFFFFFF;
ctrl->oid = LDB_CONTROL_DIRSYNC_EX_OID;
ctrl->critical = crit;
control = talloc(ctrl, struct ldb_dirsync_control);
control->flags = flags;
control->max_attributes = max_attrs;
if (*cookie) {
control->cookie_len = ldb_base64_decode(cookie);
control->cookie = (char *)talloc_memdup(control, cookie, control->cookie_len);
} else {
control->cookie = NULL;
control->cookie_len = 0;
}
ctrl->data = control;
return ctrl;
}
if (LDB_CONTROL_CMP(control_strings, LDB_CONTROL_ASQ_NAME) == 0) {
struct ldb_asq_control *control;
......
......@@ -586,6 +586,12 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
p++;
*d++ = '\0';
/*
* This talloc_memdup() is OK with the
* +1 because *d has been set to '\0'
* just above
*/
dn->components[dn->comp_num].value.data = \
(uint8_t *)talloc_memdup(dn->components, dt, l + 1);
dn->components[dn->comp_num].value.length = l;
......@@ -708,6 +714,11 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
}
*d++ = '\0';
/*
* This talloc_memdup() is OK with the
* +1 because *d has been set to '\0'
* just above.
*/
dn->components[dn->comp_num].value.length = l;
dn->components[dn->comp_num].value.data =
(uint8_t *)talloc_memdup(dn->components, dt, l + 1);
......@@ -1901,17 +1912,37 @@ int ldb_dn_set_component(struct ldb_dn *dn, int num,
return LDB_ERR_OTHER;
}
if (num < 0) {
return LDB_ERR_OTHER;
}
if (val.length > val.length + 1) {
return LDB_ERR_OTHER;
}
n = talloc_strdup(dn, name);
if ( ! n) {
return LDB_ERR_OTHER;
}
v.length = val.length;
v.data = (uint8_t *)talloc_memdup(dn, val.data, v.length+1);
/*
* This is like talloc_memdup(dn, v.data, v.length + 1), but
* avoids the over-read
*/
v.data = (uint8_t *)talloc_size(dn, v.length+1);
if ( ! v.data) {
talloc_free(n);
return LDB_ERR_OTHER;
}
memcpy(v.data, val.data, val.length);
/*
* Enforce NUL termination outside the stated length, as is
* traditional in LDB
*/
v.data[v.length] = '\0';
talloc_free(dn->components[num].name);
talloc_free(dn->components[num].value.data);
......
/*
/*
ldb database library
Copyright (C) Andrew Tridgell 2004
......@@ -6,7 +6,7 @@
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
** under the LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
......@@ -39,7 +39,7 @@
#include "system/locale.h"
/*
*/
static int ldb_read_data_file(TALLOC_CTX *mem_ctx, struct ldb_val *value)
{
......@@ -236,7 +236,7 @@ static int fold_string(int (*fprintf_fn)(void *, const char *, ...), void *priva
encode as base64 to a file
*/
static int base64_encode_f(struct ldb_context *ldb,
int (*fprintf_fn)(void *, const char *, ...),
int (*fprintf_fn)(void *, const char *, ...),
void *private_data,
const char *buf, int len, int start_pos)
{
......@@ -273,9 +273,9 @@ static const struct {
write to ldif, using a caller supplied write method, and only printing secrets if we are not in a trace
*/
static int ldb_ldif_write_trace(struct ldb_context *ldb,
int (*fprintf_fn)(void *, const char *, ...),
int (*fprintf_fn)(void *, const char *, ...),
void *private_data,
const struct ldb_ldif *ldif,
const struct ldb_ldif *ldif,
bool in_trace)
{
TALLOC_CTX *mem_ctx;
......@@ -324,20 +324,20 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
if (ldif->changetype == LDB_CHANGETYPE_MODIFY) {
switch (msg->elements[i].flags & LDB_FLAG_MOD_MASK) {
case LDB_FLAG_MOD_ADD:
fprintf_fn(private_data, "add: %s\n",
fprintf_fn(private_data, "add: %s\n",
msg->elements[i].name);
break;
case LDB_FLAG_MOD_DELETE:
fprintf_fn(private_data, "delete: %s\n",
fprintf_fn(private_data, "delete: %s\n",
msg->elements[i].name);
break;
case LDB_FLAG_MOD_REPLACE:
fprintf_fn(private_data, "replace: %s\n",
fprintf_fn(private_data, "replace: %s\n",
msg->elements[i].name);
break;
}
}
if (in_trace && secret_attributes && ldb_attr_in_list(secret_attributes, msg->elements[i].name)) {
/* Deliberatly skip printing this password */
ret = fprintf_fn(private_data, "# %s::: REDACTED SECRET ATTRIBUTE\n",
......@@ -348,18 +348,26 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
for (j=0;j<msg->elements[i].num_values;j++) {
struct ldb_val v;
bool use_b64_encode;
bool use_b64_encode = false;
ret = a->syntax->ldif_write_fn(ldb, mem_ctx, &msg->elements[i].values[j], &v);
if (ret != LDB_SUCCESS) {
v = msg->elements[i].values[j];
}
use_b64_encode = !(ldb->flags & LDB_FLG_SHOW_BINARY)
&& ldb_should_b64_encode(ldb, &v);
if (ldb->flags & LDB_FLG_SHOW_BINARY) {
use_b64_encode = false;
} else if (a->flags & LDB_ATTR_FLAG_FORCE_BASE64_LDIF) {
use_b64_encode = true;
} else {
use_b64_encode = ldb_should_b64_encode(ldb, &v);
}
if (ret != LDB_SUCCESS || use_b64_encode) {
ret = fprintf_fn(private_data, "%s:: ",
ret = fprintf_fn(private_data, "%s:: ",
msg->elements[i].name);
CHECK_RET;
ret = base64_encode_f(ldb, fprintf_fn, private_data,
ret = base64_encode_f(ldb, fprintf_fn, private_data,
(char *)v.data, v.length,
strlen(msg->elements[i].name)+3);
CHECK_RET;
......@@ -369,7 +377,7 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
ret = fprintf_fn(private_data, "%s: ", msg->elements[i].name);
CHECK_RET;
if (ldb->flags & LDB_FLG_SHOW_BINARY) {
ret = fprintf_fn(private_data, "%*.*s",
ret = fprintf_fn(private_data, "%*.*s",
v.length, v.length, (char *)v.data);
} else {
ret = fold_string(fprintf_fn, private_data,
......@@ -403,7 +411,7 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
write to ldif, using a caller supplied write method
*/
int ldb_ldif_write(struct ldb_context *ldb,
int (*fprintf_fn)(void *, const char *, ...),
int (*fprintf_fn)(void *, const char *, ...),
void *private_data,
const struct ldb_ldif *ldif)
{
......@@ -417,7 +425,7 @@ int ldb_ldif_write(struct ldb_context *ldb,
caller frees
*/
static char *next_chunk(struct ldb_context *ldb,
static char *next_chunk(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
int (*fgetc_fn)(void *), void *private_data)
{
size_t alloc_size=0, chunk_size = 0;
......@@ -429,7 +437,7 @@ static char *next_chunk(struct ldb_context *ldb,
if (chunk_size+1 >= alloc_size) {
char *c2;
alloc_size += 1024;
c2 = talloc_realloc(ldb, chunk, char, alloc_size);
c2 = talloc_realloc(mem_ctx, chunk, char, alloc_size);
if (!c2) {
talloc_free(chunk);
errno = ENOMEM;
......@@ -442,15 +450,15 @@ static char *next_chunk(struct ldb_context *ldb,
if (c == '\n') {
in_comment = 0;
}
continue;
continue;
}
/* handle continuation lines - see RFC2849 */
if (c == ' ' && chunk_size > 1 && chunk[chunk_size-1] == '\n') {
chunk_size--;
continue;
}
/* chunks are terminated by a double line-feed */
if (c == '\n' && chunk_size > 0 && chunk[chunk_size-1] == '\n') {
chunk[chunk_size-1] = 0;
......@@ -774,18 +782,17 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
msg->elements = NULL;
msg->num_elements = 0;
chunk = next_chunk(ldb, fgetc_fn, private_data);
chunk = next_chunk(ldb, ldif, fgetc_fn, private_data);
if (!chunk) {
goto failed;
}
talloc_steal(ldif, chunk);
s = chunk;
if (next_attr(ldif, &s, &attr, &value) != 0) {
goto failed;
}
/* first line must be a dn */
if (ldb_attr_cmp(attr, "dn") != 0) {
ldb_debug(ldb, LDB_DEBUG_ERROR, "Error: First line of ldif must be a dn not '%s'",
......@@ -845,7 +852,7 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
}
continue;
}
el = &msg->elements[msg->num_elements-1];
a = ldb_schema_attribute_by_name(ldb, attr);
......@@ -853,8 +860,8 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
if (msg->num_elements > 0 && ldb_attr_cmp(attr, el->name) == 0 &&
flags == el->flags) {
/* its a continuation */
el->values =
talloc_realloc(msg->elements, el->values,
el->values =
talloc_realloc(msg->elements, el->values,
struct ldb_val, el->num_values+1);
if (!el->values) {
goto failed;
......@@ -874,8 +881,8 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
el->num_values++;
} else {
/* its a new attribute */
msg->elements = talloc_realloc(msg, msg->elements,
struct ldb_message_element,
msg->elements = talloc_realloc(msg, msg->elements,
struct ldb_message_element,
msg->num_elements+1);
if (!msg->elements) {
goto failed;
......@@ -934,7 +941,7 @@ static int fgetc_file(void *private_data)
return c;
}
struct ldb_ldif *ldb_ldif_read_file_state(struct ldb_context *ldb,
struct ldb_ldif *ldb_ldif_read_file_state(struct ldb_context *ldb,
struct ldif_read_file_state *state)
{
return ldb_ldif_read(ldb, fgetc_file, state);
......@@ -1020,7 +1027,7 @@ static int ldif_printf_string(void *private_data, const char *fmt, ...)
va_list ap;
size_t oldlen = talloc_get_size(state->string);
va_start(ap, fmt);
state->string = talloc_vasprintf_append(state->string, fmt, ap);
va_end(ap);
if (!state->string) {
......@@ -1030,7 +1037,7 @@ static int ldif_printf_string(void *private_data, const char *fmt, ...)
return talloc_get_size(state->string) - oldlen;
}
char *ldb_ldif_write_redacted_trace_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
char *ldb_ldif_write_redacted_trace_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
const struct ldb_ldif *ldif)
{
struct ldif_write_string_state state;
......@@ -1044,7 +1051,7 @@ char *ldb_ldif_write_redacted_trace_string(struct ldb_context *ldb, TALLOC_CTX *
return state.string;
}
char *ldb_ldif_write_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
char *ldb_ldif_write_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
const struct ldb_ldif *ldif)
{
struct ldif_write_string_state state;
......@@ -1062,7 +1069,7 @@ char *ldb_ldif_write_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
convenient function to turn a ldb_message into a string. Useful for
debugging
*/
char *ldb_ldif_message_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
char *ldb_ldif_message_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
enum ldb_changetype changetype,
const struct ldb_message *msg)
{
......
......@@ -503,9 +503,10 @@ static int ldb_match_extended(struct ldb_context *ldb,
rule = ldb_find_extended_match_rule(ldb, tree->u.extended.rule_id);
if (rule == NULL) {
*matched = false;
ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb: unknown extended rule_id %s",
tree->u.extended.rule_id);
return LDB_ERR_INAPPROPRIATE_MATCHING;
return LDB_SUCCESS;
}
return rule->callback(ldb, rule->oid, msg,
......@@ -712,7 +713,7 @@ int ldb_register_extended_match_rule(struct ldb_context *ldb,
return LDB_ERR_OPERATIONS_ERROR;
}
entry->rule = rule;
DLIST_ADD_END(ldb->extended_match_rules, entry, struct ldb_extended_match_entry);
DLIST_ADD_END(ldb->extended_match_rules, entry);
return LDB_SUCCESS;
}
......
......@@ -162,7 +162,7 @@ int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn, bool
talloc_free(be);
return LDB_ERR_OPERATIONS_ERROR;
}
DLIST_ADD_END(ldb_backends, be, struct backends_list_entry);
DLIST_ADD_END(ldb_backends, be);
}
be->ops->name = url_prefix;
......@@ -240,7 +240,7 @@ int ldb_register_hook(ldb_hook_fn hook_fn)
return LDB_ERR_OPERATIONS_ERROR;
}
lc->hook_fn = hook_fn;
DLIST_ADD_END(ldb_hooks, lc, struct ldb_hooks);
DLIST_ADD_END(ldb_hooks, lc);
return LDB_SUCCESS;
}
......@@ -926,7 +926,7 @@ static int ldb_modules_load_path(const char *path, const char *version)
le->st_ino = st.st_ino;
le->st_dev = st.st_dev;
DLIST_ADD_END(loaded, le, struct loaded);
DLIST_ADD_END(loaded, le);
/* if it is a directory, recurse */
if (S_ISDIR(st.st_mode)) {
......
......@@ -77,7 +77,7 @@ int ldb_pack_data(struct ldb_context *ldb,
struct ldb_val *data)
{
unsigned int i, j, real_elements=0;
size_t size;
size_t size, dn_len, attr_len, value_len;
const char *dn;
uint8_t *p;
size_t len;
......@@ -91,8 +91,19 @@ int ldb_pack_data(struct ldb_context *ldb,
/* work out how big it needs to be */
size = 8;
size += 1 + strlen(dn);
size += 1;
dn_len = strlen(dn);
if (size + dn_len < size) {
errno = ENOMEM;
return -1;
}
size += dn_len;
/*
* First calcuate the buffer size we need, and check for
* overflows
*/
for (i=0;i<message->num_elements;i++) {
if (attribute_storable_values(&message->elements[i]) == 0) {
continue;
......@@ -100,9 +111,32 @@ int ldb_pack_data(struct ldb_context *ldb,
real_elements++;
size += 1 + strlen(message->elements[i].name) + 4;
if (size + 5 < size) {
errno = ENOMEM;
return -1;
}
size += 5;
attr_len = strlen(message->elements[i].name);
if (size + attr_len < size) {
errno = ENOMEM;
return -1;
}
size += attr_len;
for (j=0;j<message->elements[i].num_values;j++) {
size += 4 + message->elements[i].values[j].length + 1;
if (size + 5 < size) {
errno = ENOMEM;
return -1;
}
size += 5;
value_len = message->elements[i].values[j].length;
if (size + value_len < size) {
errno = ENOMEM;
return -1;