This way the size is the same on all archs and 32bit should be good enough.
OK rob@
-/* $OpenBSD: ber.c,v 1.24 2018/07/13 08:50:38 rob Exp $ */
+/* $OpenBSD: ber.c,v 1.25 2018/07/31 11:01:00 claudio Exp $ */
/*
* Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
static void ber_dump_header(struct ber *ber, struct ber_element *root);
static void ber_putc(struct ber *ber, u_char c);
static void ber_write(struct ber *ber, void *buf, size_t len);
-static ssize_t get_id(struct ber *b, unsigned long *tag, int *class,
+static ssize_t get_id(struct ber *b, unsigned int *tag, int *class,
int *cstruct);
static ssize_t get_len(struct ber *b, ssize_t *len);
static ssize_t ber_read_element(struct ber *ber, struct ber_element *elm);
#endif
struct ber_element *
-ber_get_element(unsigned long encoding)
+ber_get_element(unsigned int encoding)
{
struct ber_element *elm;
}
void
-ber_set_header(struct ber_element *elm, int class, unsigned long type)
+ber_set_header(struct ber_element *elm, int class, unsigned int type)
{
elm->be_class = class & BER_CLASS_MASK;
if (type == BER_TYPE_DEFAULT)
va_list ap;
int d, class;
size_t len;
- unsigned long type;
+ unsigned int type;
long long i;
char *s;
void *p;
break;
case 't':
class = va_arg(ap, int);
- type = va_arg(ap, unsigned long);
+ type = va_arg(ap, unsigned int);
ber_set_header(ber, class, type);
break;
case 'x':
#define _MAX_SEQ 128
va_list ap;
int *d, level = -1;
- unsigned long *t;
+ unsigned int *t;
long long *i, l;
void **ptr;
size_t *len, ret = 0, n = strlen(fmt);
break;
case 't':
d = va_arg(ap, int *);
- t = va_arg(ap, unsigned long *);
+ t = va_arg(ap, unsigned int *);
*d = ber->be_class;
*t = ber->be_type;
ret++;
size_t
ber_calc_len(struct ber_element *root)
{
- unsigned long t;
+ unsigned int t;
size_t s;
size_t size = 2; /* minimum 1 byte head and 1 byte size */
static void
ber_dump_header(struct ber *ber, struct ber_element *root)
{
- u_char id = 0, t, buf[8];
- unsigned long type;
+ u_char id = 0, t, buf[5];
+ unsigned int type;
size_t size;
/* class universal, type encoding depending on type value */
* extract a BER encoded tag. There are two types, a short and long form.
*/
static ssize_t
-get_id(struct ber *b, unsigned long *tag, int *class, int *cstruct)
+get_id(struct ber *b, unsigned int *tag, int *class, int *cstruct)
{
u_char u;
size_t i = 0;
- unsigned long t = 0;
+ unsigned int t = 0;
if (ber_getc(b, &u) == -1)
return -1;
return -1;
t = (t << 7) | (u & ~BER_TAG_MORE);
i++;
- if (i > sizeof(unsigned long)) {
+ if (i > sizeof(unsigned int)) {
errno = ERANGE;
return -1;
}
{
long long val = 0;
struct ber_element *next;
- unsigned long type;
+ unsigned int type;
int i, class, cstruct;
ssize_t len, r, totlen = 0;
u_char c;
}
void
-ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *))
+ber_set_application(struct ber *b, unsigned int (*cb)(struct ber_element *))
{
b->br_application = cb;
}
-/* $OpenBSD: ber.h,v 1.5 2018/07/03 18:49:10 rob Exp $ */
+/* $OpenBSD: ber.h,v 1.6 2018/07/31 11:01:00 claudio Exp $ */
/*
* Copyright (c) 2007, 2012 Reyk Floeter <reyk@openbsd.org>
struct ber_element {
struct ber_element *be_next;
- unsigned long be_type;
- unsigned long be_encoding;
+ unsigned int be_type;
+ unsigned int be_encoding;
size_t be_len;
off_t be_offs;
int be_free;
u_char *br_rptr;
u_char *br_rend;
- unsigned long (*br_application)(struct ber_element *);
+ unsigned int (*br_application)(struct ber_element *);
};
/* well-known ber_element types */
-#define BER_TYPE_DEFAULT ((unsigned long)-1)
+#define BER_TYPE_DEFAULT ((unsigned int)-1)
#define BER_TYPE_EOC 0
#define BER_TYPE_BOOLEAN 1
#define BER_TYPE_INTEGER 2
};
__BEGIN_DECLS
-struct ber_element *ber_get_element(unsigned long);
+struct ber_element *ber_get_element(unsigned int);
void ber_set_header(struct ber_element *, int,
- unsigned long);
+ unsigned int);
void ber_link_elements(struct ber_element *,
struct ber_element *);
struct ber_element *ber_unlink_elements(struct ber_element *);
void ber_free_elements(struct ber_element *);
size_t ber_calc_len(struct ber_element *);
void ber_set_application(struct ber *,
- unsigned long (*)(struct ber_element *));
+ unsigned int (*)(struct ber_element *));
void ber_set_writecallback(struct ber_element *,
void (*)(void *, size_t), void *);
void ber_free(struct ber *);
-/* $OpenBSD: conn.c,v 1.16 2018/05/15 11:19:21 reyk Exp $ */
+/* $OpenBSD: conn.c,v 1.17 2018/07/31 11:01:00 claudio Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
int conn_dispatch(struct conn *conn);
int conn_tls_init(struct conn *);
-unsigned long ldap_application(struct ber_element *elm);
+unsigned int ldap_application(struct ber_element *elm);
struct conn_list conn_list;
-unsigned long
+unsigned int
ldap_application(struct ber_element *elm)
{
return BER_TYPE_OCTETSTRING;
{
unsigned long i;
struct {
- unsigned long type;
+ unsigned int type;
int (*fn)(struct request *);
} requests[] = {
{ LDAP_REQ_SEARCH, ldap_search },
}
if (requests[i].fn == NULL) {
- log_warnx("unhandled request %lu (not implemented)", req->type);
+ log_warnx("unhandled request %u (not implemented)", req->type);
ldap_respond(req, LDAP_PROTOCOL_ERROR);
}
}
ldap_debug_elements(req->root, req->type,
"received request on fd %d", conn->fd);
- log_debug("got request type %lu, id %lld", req->type, req->msgid);
+ log_debug("got request type %u, id %lld", req->type, req->msgid);
request_dispatch(req);
return 0;
}
-/* $OpenBSD: filter.c,v 1.5 2018/05/15 11:19:21 reyk Exp $ */
+/* $OpenBSD: filter.c,v 1.6 2018/07/31 11:01:00 claudio Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martinh@openbsd.org>
ldap_filt_subs_value(struct ber_element *v, struct ber_element *sub)
{
int class;
- unsigned long type;
+ unsigned int type;
const char *cmpval;
char *vs, *p, *end;
return 1; /* no match */
break;
default:
- log_warnx("invalid subfilter type %lu", type);
+ log_warnx("invalid subfilter type %u", type);
return -1;
}
}
-/* $OpenBSD: ldapd.h,v 1.30 2018/05/15 11:19:21 reyk Exp $ */
+/* $OpenBSD: ldapd.h,v 1.31 2018/07/31 11:01:00 claudio Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
*/
struct request {
TAILQ_ENTRY(request) next;
- unsigned long type;
+ unsigned int type;
long long msgid;
struct ber_element *root;
struct ber_element *op;
int ldap_extended(struct request *req);
void send_ldap_result(struct conn *conn, int msgid,
- unsigned long type, long long result_code);
+ unsigned int type, long long result_code);
int ldap_respond(struct request *req, int code);
int ldap_refer(struct request *req, const char *basedn,
struct search *search, struct referrals *refs);
-/* $OpenBSD: ldape.c,v 1.28 2018/07/04 10:05:56 rob Exp $ */
+/* $OpenBSD: ldape.c,v 1.29 2018/07/31 11:01:00 claudio Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
int ldap_starttls(struct request *req);
void send_ldap_extended_response(struct conn *conn,
- int msgid, unsigned long type,
+ int msgid, unsigned int type,
long long result_code,
const char *extended_oid);
}
void
-send_ldap_extended_response(struct conn *conn, int msgid, unsigned long type,
+send_ldap_extended_response(struct conn *conn, int msgid, unsigned int type,
long long result_code, const char *extended_oid)
{
int rc;
struct ber_element *root, *elm;
void *buf;
- log_debug("sending response %lu with result %lld", type, result_code);
+ log_debug("sending response %u with result %lld", type, result_code);
if ((root = ber_add_sequence(NULL)) == NULL)
goto fail;
struct ber_element *root, *elm, *ref_root = NULL;
struct referral *ref;
long long result_code = LDAP_REFERRAL;
- unsigned long type;
+ unsigned int type;
int rc;
void *buf;
char *url, *scope_str = NULL;
scope_str = "sub";
}
- log_debug("sending referral in response %lu on msgid %lld",
+ log_debug("sending referral in response %u on msgid %lld",
type, req->msgid);
if ((root = ber_add_sequence(NULL)) == NULL)
}
void
-send_ldap_result(struct conn *conn, int msgid, unsigned long type,
+send_ldap_result(struct conn *conn, int msgid, unsigned int type,
long long result_code)
{
send_ldap_extended_response(conn, msgid, type, result_code, NULL);
-/* $OpenBSD: logmsg.c,v 1.2 2018/05/15 11:19:21 reyk Exp $ */
+/* $OpenBSD: logmsg.c,v 1.3 2018/07/31 11:01:00 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
break;
case BER_CLASS_PRIVATE:
fprintf(stderr, "class: private(%u) type: ", root->be_class);
- fprintf(stderr, "encoding (%lu) type: ", root->be_encoding);
+ fprintf(stderr, "encoding (%u) type: ", root->be_encoding);
break;
case BER_CLASS_CONTEXT:
fprintf(stderr, "class: context(%u) type: ", root->be_class);
fprintf(stderr, "class: <INVALID>(%u) type: ", root->be_class);
break;
}
- fprintf(stderr, "(%lu) encoding %lu ",
+ fprintf(stderr, "(%u) encoding %u ",
root->be_type, root->be_encoding);
if (constructed)
-/* $OpenBSD: search.c,v 1.22 2018/05/18 12:36:30 reyk Exp $ */
+/* $OpenBSD: search.c,v 1.23 2018/07/31 11:01:00 claudio Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se>
}
elm = ber_printf_elements(root, "i{txe", search->req->msgid,
- BER_CLASS_APP, (unsigned long)LDAP_RES_SEARCH_ENTRY,
+ BER_CLASS_APP, LDAP_RES_SEARCH_ENTRY,
dn, dnlen, filtered_attrs);
if (elm == NULL)
goto fail;
search_planner(struct namespace *ns, struct ber_element *filter)
{
int class;
- unsigned long type;
+ unsigned int type;
char *s, *attr;
struct ber_element *elm;
struct index *indx;
break;
default:
- log_warnx("filter type %lu not implemented", filter->be_type);
+ log_warnx("filter type %u not implemented", filter->be_type);
plan->undefined = 1;
break;
}