diff options
-rw-r--r-- | usr.sbin/ldapctl/ldapctl.c | 6 | ||||
-rw-r--r-- | usr.sbin/ldapd/conn.c | 8 | ||||
-rw-r--r-- | usr.sbin/ldapd/control.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldapd/filter.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldapd/ldapd.c | 19 | ||||
-rw-r--r-- | usr.sbin/ldapd/ldapd.h | 3 | ||||
-rw-r--r-- | usr.sbin/ldapd/ldape.c | 12 | ||||
-rw-r--r-- | usr.sbin/ldapd/log.c | 136 | ||||
-rw-r--r-- | usr.sbin/ldapd/log.h | 32 | ||||
-rw-r--r-- | usr.sbin/ldapd/logmsg.c | 18 | ||||
-rw-r--r-- | usr.sbin/ldapd/namespace.c | 5 | ||||
-rw-r--r-- | usr.sbin/ldapd/search.c | 12 | ||||
-rw-r--r-- | usr.sbin/ldapd/util.c | 10 | ||||
-rw-r--r-- | usr.sbin/ldapd/validate.c | 4 |
14 files changed, 172 insertions, 101 deletions
diff --git a/usr.sbin/ldapctl/ldapctl.c b/usr.sbin/ldapctl/ldapctl.c index 502bae9e629..35006cddebc 100644 --- a/usr.sbin/ldapctl/ldapctl.c +++ b/usr.sbin/ldapctl/ldapctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapctl.c,v 1.10 2017/01/20 11:55:08 benno Exp $ */ +/* $OpenBSD: ldapctl.c,v 1.11 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -255,7 +255,7 @@ main(int argc, char *argv[]) struct imsg imsg; struct imsgbuf ibuf; - log_init(1); + log_init(1, 0); while ((ch = getopt(argc, argv, "f:r:s:v")) != -1) { switch (ch) { @@ -287,7 +287,7 @@ main(int argc, char *argv[]) if (!S_ISDIR(sb.st_mode)) errx(1, "%s is not a directory", datadir); - log_verbose(verbose); + ldap_loginit(NULL, 1, verbose); if (strcmp(argv[0], "stats") == 0) action = SHOW_STATS; diff --git a/usr.sbin/ldapd/conn.c b/usr.sbin/ldapd/conn.c index 7fcd6e043e8..fff636db48e 100644 --- a/usr.sbin/ldapd/conn.c +++ b/usr.sbin/ldapd/conn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conn.c,v 1.15 2018/02/08 18:02:06 jca Exp $ */ +/* $OpenBSD: conn.c,v 1.16 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -132,7 +132,7 @@ request_dispatch(struct request *req) } if (requests[i].fn == NULL) { - log_warnx("unhandled request %d (not implemented)", req->type); + log_warnx("unhandled request %lu (not implemented)", req->type); ldap_respond(req, LDAP_PROTOCOL_ERROR); } } @@ -166,7 +166,7 @@ conn_dispatch(struct conn *conn) request_free(req); return -1; } - log_debug("consumed %d bytes", conn->ber.br_rptr - rptr); + log_debug("consumed %ld bytes", conn->ber.br_rptr - rptr); /* Read message id and request type. */ @@ -183,7 +183,7 @@ conn_dispatch(struct conn *conn) ldap_debug_elements(req->root, req->type, "received request on fd %d", conn->fd); - log_debug("got request type %d, id %lld", req->type, req->msgid); + log_debug("got request type %lu, id %lld", req->type, req->msgid); request_dispatch(req); return 0; } diff --git a/usr.sbin/ldapd/control.c b/usr.sbin/ldapd/control.c index 2d49e300024..fa48e1be862 100644 --- a/usr.sbin/ldapd/control.c +++ b/usr.sbin/ldapd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.15 2017/01/20 11:55:08 benno Exp $ */ +/* $OpenBSD: control.c,v 1.16 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2010 Martin Hedenfalk <martin@bzero.se> @@ -261,7 +261,7 @@ control_imsgev(struct imsgev *iev, int code, struct imsg *imsg) imsgev_compose(iev_ldapd, IMSG_CTL_LOG_VERBOSE, 0, 0, -1, &verbose, sizeof(verbose)); - log_verbose(verbose); + log_setverbose(verbose); break; default: log_warnx("%s: unexpected imsg %d", __func__, imsg->hdr.type); diff --git a/usr.sbin/ldapd/filter.c b/usr.sbin/ldapd/filter.c index b70297c0b71..a56b14b2bf4 100644 --- a/usr.sbin/ldapd/filter.c +++ b/usr.sbin/ldapd/filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filter.c,v 1.4 2017/01/20 11:55:08 benno Exp $ */ +/* $OpenBSD: filter.c,v 1.5 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martinh@openbsd.org> @@ -101,7 +101,7 @@ ldap_filt_subs_value(struct ber_element *v, struct ber_element *sub) return 1; /* no match */ break; default: - log_warnx("invalid subfilter type %d", type); + log_warnx("invalid subfilter type %lu", type); return -1; } } diff --git a/usr.sbin/ldapd/ldapd.c b/usr.sbin/ldapd/ldapd.c index 2c1f8e50842..94df93ee4e6 100644 --- a/usr.sbin/ldapd/ldapd.c +++ b/usr.sbin/ldapd/ldapd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapd.c,v 1.23 2017/03/01 00:50:12 gsoares Exp $ */ +/* $OpenBSD: ldapd.c,v 1.24 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -36,6 +36,7 @@ #include <string.h> #include <time.h> #include <unistd.h> +#include <syslog.h> #include "ldapd.h" #include "log.h" @@ -123,7 +124,7 @@ main(int argc, char *argv[]) struct event ev_sighup; struct stat sb; - log_init(1); /* log to stderr until daemonized */ + log_init(1, LOG_DAEMON); /* log to stderr until daemonized */ saved_argv0 = argv[0]; if (saved_argv0 == NULL) @@ -180,7 +181,7 @@ main(int argc, char *argv[]) if (getpwnam(LDAPD_USER) == NULL) errx(1, "unknown user %s", LDAPD_USER); - log_verbose(verbose); + log_setverbose(verbose); stats.started_at = time(0); tls_init(); @@ -192,6 +193,8 @@ main(int argc, char *argv[]) exit(0); } + log_init(debug, LOG_DAEMON); + if (eflag) ldape(debug, verbose, csockpath); @@ -205,7 +208,6 @@ main(int argc, char *argv[]) err(1, "failed to daemonize"); } - log_init(debug); log_info("startup"); if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, @@ -215,6 +217,7 @@ main(int argc, char *argv[]) ldape_pid = start_child(PROC_LDAP_SERVER, saved_argv0, pipe_parent2ldap[1], debug, verbose, csockpath, conffile); + ldap_loginit("auth", debug, verbose); setproctitle("auth"); event_init(); @@ -374,7 +377,7 @@ ldapd_log_verbose(struct imsg *imsg) fatal("invalid size of log verbose request"); bcopy(imsg->data, &verbose, sizeof(verbose)); - log_verbose(verbose); + log_setverbose(verbose); } static void @@ -439,7 +442,11 @@ start_child(enum ldapd_process p, char *argv0, int fd, int debug, } if (debug) argv[argc++] = "-d"; - if (verbose) + if (verbose >= 3) + argv[argc++] = "-vvv"; + else if (verbose == 2) + argv[argc++] = "-vv"; + else if (verbose == 1) argv[argc++] = "-v"; if (csockpath) { argv[argc++] = "-s"; diff --git a/usr.sbin/ldapd/ldapd.h b/usr.sbin/ldapd/ldapd.h index bc9b53e0c67..f6249594537 100644 --- a/usr.sbin/ldapd/ldapd.h +++ b/usr.sbin/ldapd/ldapd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ldapd.h,v 1.29 2018/05/14 07:53:47 reyk Exp $ */ +/* $OpenBSD: ldapd.h,v 1.30 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -471,6 +471,7 @@ SPLAY_PROTOTYPE(ssltree, ssl, ssl_nodes, ssl_cmp); /* logmsg.c */ +void ldap_loginit(const char *, int, int); const char *print_host(struct sockaddr_storage *ss, char *buf, size_t len); void hexdump(void *data, size_t len, const char *fmt, ...); diff --git a/usr.sbin/ldapd/ldape.c b/usr.sbin/ldapd/ldape.c index ecfc24d11b8..4e32683be2e 100644 --- a/usr.sbin/ldapd/ldape.c +++ b/usr.sbin/ldapd/ldape.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldape.c,v 1.26 2017/02/24 14:28:31 gsoares Exp $ */ +/* $OpenBSD: ldape.c,v 1.27 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -76,7 +76,7 @@ send_ldap_extended_response(struct conn *conn, int msgid, unsigned long type, struct ber_element *root, *elm; void *buf; - log_debug("sending response %u with result %lld", type, result_code); + log_debug("sending response %lu with result %lld", type, result_code); if ((root = ber_add_sequence(NULL)) == NULL) goto fail; @@ -133,7 +133,7 @@ ldap_refer(struct request *req, const char *basedn, struct search *search, scope_str = "sub"; } - log_debug("sending referral in response %u on msgid %lld", + log_debug("sending referral in response %lu on msgid %lld", type, req->msgid); if ((root = ber_add_sequence(NULL)) == NULL) @@ -346,11 +346,9 @@ ldape(int debug, int verbose, char *csockpath) char host[128]; mode_t old_umask = 0; - log_init(debug); - log_verbose(verbose); - TAILQ_INIT(&conn_list); + ldap_loginit("ldap server", debug, verbose); setproctitle("ldap server"); event_init(); @@ -443,7 +441,7 @@ ldape(int debug, int verbose, char *csockpath) TAILQ_FOREACH(ns, &conf->namespaces, next) { if (!namespace_has_referrals(ns) && namespace_open(ns) != 0) - fatal(ns->suffix); + fatal("%s", ns->suffix); } if ((pw = getpwnam(LDAPD_USER)) == NULL) diff --git a/usr.sbin/ldapd/log.c b/usr.sbin/ldapd/log.c index 351a2ced89c..778c2dd4f3f 100644 --- a/usr.sbin/ldapd/log.c +++ b/usr.sbin/ldapd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.8 2017/03/21 12:06:55 bluhm Exp $ */ +/* $OpenBSD: log.c,v 1.9 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -16,40 +16,73 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <sys/time.h> -#include <errno.h> -#include <stdarg.h> #include <stdio.h> #include <stdlib.h> +#include <stdarg.h> #include <string.h> #include <syslog.h> +#include <errno.h> #include <time.h> -#include <unistd.h> - -#include "log.h" -int debug; -int verbose; +static int debug; +static int verbose; +const char *log_procname; + +void log_init(int, int); +void log_procinit(const char *); +void log_setverbose(int); +int log_getverbose(void); +void log_warn(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_warnx(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_info(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_debug(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void logit(int, const char *, ...) + __attribute__((__format__ (printf, 2, 3))); +void vlog(int, const char *, va_list) + __attribute__((__format__ (printf, 2, 0))); +__dead void fatal(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +__dead void fatalx(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); void -log_init(int n_debug) +log_init(int n_debug, int facility) { extern char *__progname; debug = n_debug; + verbose = n_debug; + log_procinit(__progname); if (!debug) - openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON); + openlog(__progname, LOG_PID | LOG_NDELAY, facility); tzset(); } void -log_verbose(int v) +log_procinit(const char *procname) +{ + if (procname != NULL) + log_procname = procname; +} + +void +log_setverbose(int v) { verbose = v; } +int +log_getverbose(void) +{ + return (verbose); +} + void logit(int pri, const char *fmt, ...) { @@ -63,23 +96,10 @@ logit(int pri, const char *fmt, ...) void vlog(int pri, const char *fmt, va_list ap) { - char datebuf[24]; - struct timeval tv; - struct tm *tm; - char *nfmt; - size_t rc; - time_t now; + char *nfmt; + int saved_errno = errno; if (debug) { - gettimeofday(&tv, NULL); - now = tv.tv_sec; - tm = localtime(&now); - rc = strftime(datebuf, sizeof(datebuf), "%b %e %H:%M:%S", tm); - if (rc == 0) - datebuf[0] = 0; - fprintf(stderr, "%s.%03ld [%d] ", datebuf, - tv.tv_usec / 1000, getpid()); - /* best effort in out of mem situations */ if (asprintf(&nfmt, "%s\n", fmt) == -1) { vfprintf(stderr, fmt, ap); @@ -91,30 +111,36 @@ vlog(int pri, const char *fmt, va_list ap) fflush(stderr); } else vsyslog(pri, fmt, ap); + + errno = saved_errno; } void log_warn(const char *emsg, ...) { - char *nfmt; - va_list ap; + char *nfmt; + va_list ap; + int saved_errno = errno; /* best effort to even work in out of memory situations */ if (emsg == NULL) - logit(LOG_ERR, "%s", strerror(errno)); + logit(LOG_ERR, "%s", strerror(saved_errno)); else { va_start(ap, emsg); - if (asprintf(&nfmt, "%s: %s", emsg, strerror(errno)) == -1) { + if (asprintf(&nfmt, "%s: %s", emsg, + strerror(saved_errno)) == -1) { /* we tried it... */ vlog(LOG_ERR, emsg, ap); - logit(LOG_ERR, "%s", strerror(errno)); + logit(LOG_ERR, "%s", strerror(saved_errno)); } else { vlog(LOG_ERR, nfmt, ap); free(nfmt); } va_end(ap); } + + errno = saved_errno; } void @@ -142,31 +168,51 @@ log_debug(const char *emsg, ...) { va_list ap; - if (verbose) { + if (verbose > 1) { va_start(ap, emsg); vlog(LOG_DEBUG, emsg, ap); va_end(ap); } } -void -fatal(const char *emsg) +static void +vfatalc(int code, const char *emsg, va_list ap) { - if (emsg == NULL) - logit(LOG_CRIT, "fatal: %s", strerror(errno)); + static char s[BUFSIZ]; + const char *sep; + + if (emsg != NULL) { + (void)vsnprintf(s, sizeof(s), emsg, ap); + sep = ": "; + } else { + s[0] = '\0'; + sep = ""; + } + if (code) + logit(LOG_CRIT, "%s: %s%s%s", + log_procname, s, sep, strerror(code)); else - if (errno) - logit(LOG_CRIT, "fatal: %s: %s", - emsg, strerror(errno)); - else - logit(LOG_CRIT, "fatal: %s", emsg); + logit(LOG_CRIT, "%s%s%s", log_procname, sep, s); +} +void +fatal(const char *emsg, ...) +{ + va_list ap; + + va_start(ap, emsg); + vfatalc(errno, emsg, ap); + va_end(ap); exit(1); } void -fatalx(const char *emsg) +fatalx(const char *emsg, ...) { - errno = 0; - fatal(emsg); + va_list ap; + + va_start(ap, emsg); + vfatalc(0, emsg, ap); + va_end(ap); + exit(1); } diff --git a/usr.sbin/ldapd/log.h b/usr.sbin/ldapd/log.h index a7f77554566..d711a3d3e1f 100644 --- a/usr.sbin/ldapd/log.h +++ b/usr.sbin/ldapd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.1 2017/01/20 11:55:08 benno Exp $ */ +/* $OpenBSD: log.h,v 1.2 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -19,13 +19,23 @@ #include <stdarg.h> #include <sys/cdefs.h> -void log_init(int); -void log_verbose(int); -void logit(int, const char *, ...); -void vlog(int, const char *, va_list); -void log_warn(const char *, ...); -void log_warnx(const char *, ...); -void log_info(const char *, ...); -void log_debug(const char *, ...); -void fatal(const char *) __dead; -void fatalx(const char *) __dead; +void log_init(int, int); +void log_procinit(const char *); +void log_setverbose(int); +int log_getverbose(void); +void log_warn(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_warnx(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_info(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_debug(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void logit(int, const char *, ...) + __attribute__((__format__ (printf, 2, 3))); +void vlog(int, const char *, va_list) + __attribute__((__format__ (printf, 2, 0))); +__dead void fatal(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +__dead void fatalx(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); diff --git a/usr.sbin/ldapd/logmsg.c b/usr.sbin/ldapd/logmsg.c index 2dbbbc90421..4fe2e0f8ba6 100644 --- a/usr.sbin/ldapd/logmsg.c +++ b/usr.sbin/ldapd/logmsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logmsg.c,v 1.1 2017/01/20 11:55:08 benno Exp $ */ +/* $OpenBSD: logmsg.c,v 1.2 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -35,8 +35,16 @@ #include "ldapd.h" #include "log.h" -extern int debug; -extern int verbose; +static int debug; + +void +ldap_loginit(const char *name, int d, int v) +{ + log_setverbose(v); + if (name != NULL) + log_procinit(name); + debug = d; +} const char * print_host(struct sockaddr_storage *ss, char *buf, size_t len) @@ -55,7 +63,7 @@ hexdump(void *data, size_t len, const char *fmt, ...) uint8_t *p = data; va_list ap; - if (verbose < 2 || !debug) + if (log_getverbose() <= 2 || !debug) return; va_start(ap, fmt); @@ -90,7 +98,7 @@ ldap_debug_elements(struct ber_element *root, int context, const char *fmt, ...) int constructed; struct ber_oid o; - if (verbose < 2 || !debug) + if (log_getverbose() <= 2 || !debug) return; if (fmt != NULL) { diff --git a/usr.sbin/ldapd/namespace.c b/usr.sbin/ldapd/namespace.c index 88f50fceac2..3af166b93a6 100644 --- a/usr.sbin/ldapd/namespace.c +++ b/usr.sbin/ldapd/namespace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: namespace.c,v 1.17 2017/01/20 11:55:08 benno Exp $ */ +/* $OpenBSD: namespace.c,v 1.18 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -472,7 +472,8 @@ int namespace_queue_request(struct namespace *ns, struct request *req) { if (ns->queued_requests > MAX_REQUEST_QUEUE) { - log_warn("%u requests alreay queued, sorry"); + log_warn("%u requests already queued, sorry", + ns->queued_requests); return -1; } diff --git a/usr.sbin/ldapd/search.c b/usr.sbin/ldapd/search.c index a12593aceac..84f0fd2cbb0 100644 --- a/usr.sbin/ldapd/search.c +++ b/usr.sbin/ldapd/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.19 2018/05/14 07:53:47 reyk Exp $ */ +/* $OpenBSD: search.c,v 1.20 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -330,7 +330,7 @@ conn_search(struct search *search) op = BT_NEXT; if (rc == BT_SUCCESS && search->plan->indexed) { - log_debug("found index %.*s", key.size, key.data); + log_debug("found index %.*s", (int)key.size, key.data); if (!has_prefix(&key, search->cindx->prefix)) { log_debug("scanned past index prefix [%s]", @@ -438,7 +438,7 @@ conn_search(struct search *search) /* Check if we have passed the size limit. */ if (rc == BT_SUCCESS && search->szlim > 0 && search->nmatched >= search->szlim) { - log_debug("search %d/%lld has reached size limit (%u)", + log_debug("search %d/%lld has reached size limit (%lld)", search->conn->fd, search->req->msgid, search->szlim); reason = LDAP_SIZELIMIT_EXCEEDED; @@ -450,7 +450,7 @@ conn_search(struct search *search) now = time(0); if (rc == 0 && search->tmlim > 0 && search->started_at + search->tmlim <= now) { - log_debug("search %d/%lld has reached time limit (%u)", + log_debug("search %d/%lld has reached time limit (%lld)", search->conn->fd, search->req->msgid, search->tmlim); reason = LDAP_TIMELIMIT_EXCEEDED; @@ -803,7 +803,7 @@ search_planner(struct namespace *ns, struct ber_element *filter) break; default: - log_warnx("filter type %d not implemented", filter->be_type); + log_warnx("filter type %lu not implemented", filter->be_type); plan->undefined = 1; break; } @@ -875,7 +875,7 @@ ldap_search(struct request *req) } normalize_dn(search->basedn); - log_debug("base dn = %s, scope = %d", search->basedn, search->scope); + log_debug("base dn = %s, scope = %lld", search->basedn, search->scope); if (*search->basedn == '\0') { /* request for the root DSE */ diff --git a/usr.sbin/ldapd/util.c b/usr.sbin/ldapd/util.c index c1bb0829c9b..eb72d949dcb 100644 --- a/usr.sbin/ldapd/util.c +++ b/usr.sbin/ldapd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.9 2018/02/08 18:02:06 jca Exp $ */ +/* $OpenBSD: util.c,v 1.10 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2009 Martin Hedenfalk <martin@bzero.se> @@ -122,7 +122,7 @@ ber2db(struct ber_element *root, struct btval *val, int compression_level) val->size = compressBound(len); val->data = malloc(val->size + sizeof(uint32_t)); if (val->data == NULL) { - log_warn("malloc(%u)", val->size + sizeof(uint32_t)); + log_warn("malloc(%zu)", val->size + sizeof(uint32_t)); ber_free(&ber); return -1; } @@ -135,7 +135,7 @@ ber2db(struct ber_element *root, struct btval *val, int compression_level) ber_free(&ber); return -1; } - log_debug("compressed entry from %u -> %u byte", + log_debug("compressed entry from %zd -> %lu byte", len, destlen + sizeof(uint32_t)); *(uint32_t *)val->data = len; @@ -174,7 +174,7 @@ db2ber(struct btval *val, int compression_level) len = *(uint32_t *)val->data; if ((buf = malloc(len)) == NULL) { - log_warn("malloc(%u)", len); + log_warn("malloc(%lu)", len); return NULL; } @@ -187,7 +187,7 @@ db2ber(struct btval *val, int compression_level) return NULL; } - log_debug("uncompressed entry from %u -> %u byte", + log_debug("uncompressed entry from %zu -> %lu byte", val->size, len); ber_set_readbuf(&ber, buf, len); diff --git a/usr.sbin/ldapd/validate.c b/usr.sbin/ldapd/validate.c index 49c710928dc..45b02e7207c 100644 --- a/usr.sbin/ldapd/validate.c +++ b/usr.sbin/ldapd/validate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: validate.c,v 1.10 2017/01/20 11:55:08 benno Exp $ */ +/* $OpenBSD: validate.c,v 1.11 2018/05/15 11:19:21 reyk Exp $ */ /* * Copyright (c) 2010 Martin Hedenfalk <martin@bzero.se> @@ -80,7 +80,7 @@ validate_attribute(struct attr_type *at, struct ber_element *vals) !at->syntax->is_valid(conf->schema, val, elm->be_len)) { log_debug("%s: invalid syntax", ATTR_NAME(at)); log_debug("syntax = %s", at->syntax->desc); - log_debug("value: [%.*s]", elm->be_len, val); + log_debug("value: [%.*s]", (int)elm->be_len, val); return LDAP_INVALID_SYNTAX; } } |