This way the size is the same on all archs and 32bit should be good enough.
OK rob@
-/* $Id: aldap.c,v 1.40 2018/06/21 10:37:00 reyk Exp $ */
-/* $OpenBSD: aldap.c,v 1.40 2018/06/21 10:37:00 reyk Exp $ */
+/* $Id: aldap.c,v 1.41 2018/07/31 11:00:12 claudio Exp $ */
+/* $OpenBSD: aldap.c,v 1.41 2018/07/31 11:00:12 claudio Exp $ */
/*
* Copyright (c) 2008 Alexander Schrijver <aschrijver@openbsd.org>
int, struct aldap_page_control *);
int aldap_send(struct aldap *,
struct ber_element *);
-unsigned long aldap_application(struct ber_element *);
+unsigned int aldap_application(struct ber_element *);
#ifdef DEBUG
void ldap_debug_elements(struct ber_element *);
#define LDAP_DEBUG(x, y) do { } while (0)
#endif
-unsigned long
+unsigned int
aldap_application(struct ber_element *elm)
{
return BER_TYPE_OCTETSTRING;
goto fail;
ber = ber_printf_elements(root, "d{tst", ++ldap->msgid, BER_CLASS_APP,
- (unsigned long) LDAP_REQ_EXTENDED, LDAP_STARTTLS_OID,
- BER_CLASS_CONTEXT, (unsigned long) 0);
+ LDAP_REQ_EXTENDED, LDAP_STARTTLS_OID, BER_CLASS_CONTEXT, 0);
if (ber == NULL) {
ldap->err = ALDAP_ERR_OPERATION_FAILED;
goto fail;
goto fail;
elm = ber_printf_elements(root, "d{tdsst", ++ldap->msgid, BER_CLASS_APP,
- (unsigned long)LDAP_REQ_BIND, VERSION, binddn, bindcred,
- BER_CLASS_CONTEXT, (unsigned long)LDAP_AUTH_SIMPLE);
+ LDAP_REQ_BIND, VERSION, binddn, bindcred,
+ BER_CLASS_CONTEXT, LDAP_AUTH_SIMPLE);
if (elm == NULL)
goto fail;
goto fail;
ber = ber_printf_elements(root, "d{t", ++ldap->msgid, BER_CLASS_APP,
- (unsigned long) LDAP_REQ_SEARCH);
+ LDAP_REQ_SEARCH);
if (ber == NULL) {
ldap->err = ALDAP_ERR_OPERATION_FAILED;
goto fail;
aldap_parse(struct aldap *ldap)
{
int class;
- unsigned long type;
+ unsigned int type;
long long msgid = 0;
struct aldap_message *m;
struct ber_element *a = NULL, *ep;
-/* $OpenBSD: ber.c,v 1.26 2018/07/13 08:50:38 rob Exp $ */
+/* $OpenBSD: ber.c,v 1.27 2018/07/31 11:00:12 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.6 2018/07/03 18:49:10 rob Exp $ */
+/* $OpenBSD: ber.h,v 1.7 2018/07/31 11:00:12 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 *);