On Mon, Jul 30, 2018 at 04:39:39PM -0400, Rob Pierce wrote:
> Some public ber functions sneaked in below the internal functions comment.
> Move
> them up so the comment regains its former truthiness.
>
> Ok?
OK claudio@
> Index: usr.bin/ldap/ber.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/ldap/ber.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 ber.c
> --- usr.bin/ldap/ber.c 13 Jul 2018 08:50:38 -0000 1.14
> +++ usr.bin/ldap/ber.c 30 Jul 2018 20:20:40 -0000
> @@ -430,6 +430,32 @@ ber_string2oid(const char *oidstr, struc
> return (0);
> }
>
> +int
> +ber_oid_cmp(struct ber_oid *a, struct ber_oid *b)
> +{
> + size_t i;
> + for (i = 0; i < BER_MAX_OID_LEN; i++) {
> + if (a->bo_id[i] != 0) {
> + if (a->bo_id[i] == b->bo_id[i])
> + continue;
> + else if (a->bo_id[i] < b->bo_id[i]) {
> + /* b is a successor of a */
> + return (1);
> + } else {
> + /* b is a predecessor of a */
> + return (-1);
> + }
> + } else if (b->bo_id[i] != 0) {
> + /* b is larger, but a child of a */
> + return (2);
> + } else
> + break;
> + }
> +
> + /* b and a are identical */
> + return (0);
> +}
> +
> struct ber_element *
> ber_add_oid(struct ber_element *prev, struct ber_oid *o)
> {
> @@ -756,6 +782,15 @@ ber_scanf_elements(struct ber_element *b
>
> }
>
> +ssize_t
> +ber_get_writebuf(struct ber *b, void **buf)
> +{
> + if (b->br_wbuf == NULL)
> + return -1;
> + *buf = b->br_wbuf;
> + return (b->br_wend - b->br_wbuf);
> +}
> +
> /*
> * write ber elements to the write buffer
> *
> @@ -795,6 +830,13 @@ ber_write_elements(struct ber *ber, stru
> return (len);
> }
>
> +void
> +ber_set_readbuf(struct ber *b, void *buf, size_t len)
> +{
> + b->br_rbuf = b->br_rptr = buf;
> + b->br_rend = (u_int8_t *)buf + len;
> +}
> +
> /*
> * read ber elements from the read buffer
> *
> @@ -896,6 +938,26 @@ ber_calc_len(struct ber_element *root)
> return (root->be_len + size);
> }
>
> +void
> +ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *))
> +{
> + b->br_application = cb;
> +}
> +
> +void
> +ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t),
> + void *arg)
> +{
> + elm->be_cb = cb;
> + elm->be_cbarg = arg;
> +}
> +
> +void
> +ber_free(struct ber *b)
> +{
> + free(b->br_wbuf);
> +}
> +
> /*
> * internal functions
> */
> @@ -1204,42 +1266,6 @@ ber_read_element(struct ber *ber, struct
> return totlen;
> }
>
> -void
> -ber_set_readbuf(struct ber *b, void *buf, size_t len)
> -{
> - b->br_rbuf = b->br_rptr = buf;
> - b->br_rend = (u_int8_t *)buf + len;
> -}
> -
> -ssize_t
> -ber_get_writebuf(struct ber *b, void **buf)
> -{
> - if (b->br_wbuf == NULL)
> - return -1;
> - *buf = b->br_wbuf;
> - return (b->br_wend - b->br_wbuf);
> -}
> -
> -void
> -ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *))
> -{
> - b->br_application = cb;
> -}
> -
> -void
> -ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t),
> - void *arg)
> -{
> - elm->be_cb = cb;
> - elm->be_cbarg = arg;
> -}
> -
> -void
> -ber_free(struct ber *b)
> -{
> - free(b->br_wbuf);
> -}
> -
> static ssize_t
> ber_getc(struct ber *b, u_char *c)
> {
> @@ -1265,30 +1291,4 @@ ber_read(struct ber *ber, void *buf, siz
> ber->br_offs += len;
>
> return len;
> -}
> -
> -int
> -ber_oid_cmp(struct ber_oid *a, struct ber_oid *b)
> -{
> - size_t i;
> - for (i = 0; i < BER_MAX_OID_LEN; i++) {
> - if (a->bo_id[i] != 0) {
> - if (a->bo_id[i] == b->bo_id[i])
> - continue;
> - else if (a->bo_id[i] < b->bo_id[i]) {
> - /* b is a successor of a */
> - return (1);
> - } else {
> - /* b is a predecessor of a */
> - return (-1);
> - }
> - } else if (b->bo_id[i] != 0) {
> - /* b is larger, but a child of a */
> - return (2);
> - } else
> - break;
> - }
> -
> - /* b and a are identical */
> - return (0);
> }
> Index: usr.sbin/ldapd/ber.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ldapd/ber.c,v
> retrieving revision 1.24
> diff -u -p -r1.24 ber.c
> --- usr.sbin/ldapd/ber.c 13 Jul 2018 08:50:38 -0000 1.24
> +++ usr.sbin/ldapd/ber.c 30 Jul 2018 20:21:58 -0000
> @@ -430,6 +430,32 @@ ber_string2oid(const char *oidstr, struc
> return (0);
> }
>
> +int
> +ber_oid_cmp(struct ber_oid *a, struct ber_oid *b)
> +{
> + size_t i;
> + for (i = 0; i < BER_MAX_OID_LEN; i++) {
> + if (a->bo_id[i] != 0) {
> + if (a->bo_id[i] == b->bo_id[i])
> + continue;
> + else if (a->bo_id[i] < b->bo_id[i]) {
> + /* b is a successor of a */
> + return (1);
> + } else {
> + /* b is a predecessor of a */
> + return (-1);
> + }
> + } else if (b->bo_id[i] != 0) {
> + /* b is larger, but a child of a */
> + return (2);
> + } else
> + break;
> + }
> +
> + /* b and a are identical */
> + return (0);
> +}
> +
> struct ber_element *
> ber_add_oid(struct ber_element *prev, struct ber_oid *o)
> {
> @@ -756,6 +782,15 @@ ber_scanf_elements(struct ber_element *b
>
> }
>
> +ssize_t
> +ber_get_writebuf(struct ber *b, void **buf)
> +{
> + if (b->br_wbuf == NULL)
> + return -1;
> + *buf = b->br_wbuf;
> + return (b->br_wend - b->br_wbuf);
> +}
> +
> /*
> * write ber elements to the write buffer
> *
> @@ -795,6 +830,13 @@ ber_write_elements(struct ber *ber, stru
> return (len);
> }
>
> +void
> +ber_set_readbuf(struct ber *b, void *buf, size_t len)
> +{
> + b->br_rbuf = b->br_rptr = buf;
> + b->br_rend = (u_int8_t *)buf + len;
> +}
> +
> /*
> * read ber elements from the read buffer
> *
> @@ -896,6 +938,26 @@ ber_calc_len(struct ber_element *root)
> return (root->be_len + size);
> }
>
> +void
> +ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *))
> +{
> + b->br_application = cb;
> +}
> +
> +void
> +ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t),
> + void *arg)
> +{
> + elm->be_cb = cb;
> + elm->be_cbarg = arg;
> +}
> +
> +void
> +ber_free(struct ber *b)
> +{
> + free(b->br_wbuf);
> +}
> +
> /*
> * internal functions
> */
> @@ -1204,42 +1266,6 @@ ber_read_element(struct ber *ber, struct
> return totlen;
> }
>
> -void
> -ber_set_readbuf(struct ber *b, void *buf, size_t len)
> -{
> - b->br_rbuf = b->br_rptr = buf;
> - b->br_rend = (u_int8_t *)buf + len;
> -}
> -
> -ssize_t
> -ber_get_writebuf(struct ber *b, void **buf)
> -{
> - if (b->br_wbuf == NULL)
> - return -1;
> - *buf = b->br_wbuf;
> - return (b->br_wend - b->br_wbuf);
> -}
> -
> -void
> -ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *))
> -{
> - b->br_application = cb;
> -}
> -
> -void
> -ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t),
> - void *arg)
> -{
> - elm->be_cb = cb;
> - elm->be_cbarg = arg;
> -}
> -
> -void
> -ber_free(struct ber *b)
> -{
> - free(b->br_wbuf);
> -}
> -
> static ssize_t
> ber_getc(struct ber *b, u_char *c)
> {
> @@ -1265,30 +1291,4 @@ ber_read(struct ber *ber, void *buf, siz
> ber->br_offs += len;
>
> return len;
> -}
> -
> -int
> -ber_oid_cmp(struct ber_oid *a, struct ber_oid *b)
> -{
> - size_t i;
> - for (i = 0; i < BER_MAX_OID_LEN; i++) {
> - if (a->bo_id[i] != 0) {
> - if (a->bo_id[i] == b->bo_id[i])
> - continue;
> - else if (a->bo_id[i] < b->bo_id[i]) {
> - /* b is a successor of a */
> - return (1);
> - } else {
> - /* b is a predecessor of a */
> - return (-1);
> - }
> - } else if (b->bo_id[i] != 0) {
> - /* b is larger, but a child of a */
> - return (2);
> - } else
> - break;
> - }
> -
> - /* b and a are identical */
> - return (0);
> }
> Index: usr.sbin/snmpd/ber.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/snmpd/ber.c,v
> retrieving revision 1.43
> diff -u -p -r1.43 ber.c
> --- usr.sbin/snmpd/ber.c 13 Jul 2018 08:50:38 -0000 1.43
> +++ usr.sbin/snmpd/ber.c 30 Jul 2018 20:22:49 -0000
> @@ -430,6 +430,32 @@ ber_string2oid(const char *oidstr, struc
> return (0);
> }
>
> +int
> +ber_oid_cmp(struct ber_oid *a, struct ber_oid *b)
> +{
> + size_t i;
> + for (i = 0; i < BER_MAX_OID_LEN; i++) {
> + if (a->bo_id[i] != 0) {
> + if (a->bo_id[i] == b->bo_id[i])
> + continue;
> + else if (a->bo_id[i] < b->bo_id[i]) {
> + /* b is a successor of a */
> + return (1);
> + } else {
> + /* b is a predecessor of a */
> + return (-1);
> + }
> + } else if (b->bo_id[i] != 0) {
> + /* b is larger, but a child of a */
> + return (2);
> + } else
> + break;
> + }
> +
> + /* b and a are identical */
> + return (0);
> +}
> +
> struct ber_element *
> ber_add_oid(struct ber_element *prev, struct ber_oid *o)
> {
> @@ -756,6 +782,15 @@ ber_scanf_elements(struct ber_element *b
>
> }
>
> +ssize_t
> +ber_get_writebuf(struct ber *b, void **buf)
> +{
> + if (b->br_wbuf == NULL)
> + return -1;
> + *buf = b->br_wbuf;
> + return (b->br_wend - b->br_wbuf);
> +}
> +
> /*
> * write ber elements to the write buffer
> *
> @@ -795,6 +830,13 @@ ber_write_elements(struct ber *ber, stru
> return (len);
> }
>
> +void
> +ber_set_readbuf(struct ber *b, void *buf, size_t len)
> +{
> + b->br_rbuf = b->br_rptr = buf;
> + b->br_rend = (u_int8_t *)buf + len;
> +}
> +
> /*
> * read ber elements from the read buffer
> *
> @@ -896,6 +938,26 @@ ber_calc_len(struct ber_element *root)
> return (root->be_len + size);
> }
>
> +void
> +ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *))
> +{
> + b->br_application = cb;
> +}
> +
> +void
> +ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t),
> + void *arg)
> +{
> + elm->be_cb = cb;
> + elm->be_cbarg = arg;
> +}
> +
> +void
> +ber_free(struct ber *b)
> +{
> + free(b->br_wbuf);
> +}
> +
> /*
> * internal functions
> */
> @@ -1204,42 +1266,6 @@ ber_read_element(struct ber *ber, struct
> return totlen;
> }
>
> -void
> -ber_set_readbuf(struct ber *b, void *buf, size_t len)
> -{
> - b->br_rbuf = b->br_rptr = buf;
> - b->br_rend = (u_int8_t *)buf + len;
> -}
> -
> -ssize_t
> -ber_get_writebuf(struct ber *b, void **buf)
> -{
> - if (b->br_wbuf == NULL)
> - return -1;
> - *buf = b->br_wbuf;
> - return (b->br_wend - b->br_wbuf);
> -}
> -
> -void
> -ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *))
> -{
> - b->br_application = cb;
> -}
> -
> -void
> -ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t),
> - void *arg)
> -{
> - elm->be_cb = cb;
> - elm->be_cbarg = arg;
> -}
> -
> -void
> -ber_free(struct ber *b)
> -{
> - free(b->br_wbuf);
> -}
> -
> static ssize_t
> ber_getc(struct ber *b, u_char *c)
> {
> @@ -1265,30 +1291,4 @@ ber_read(struct ber *ber, void *buf, siz
> ber->br_offs += len;
>
> return len;
> -}
> -
> -int
> -ber_oid_cmp(struct ber_oid *a, struct ber_oid *b)
> -{
> - size_t i;
> - for (i = 0; i < BER_MAX_OID_LEN; i++) {
> - if (a->bo_id[i] != 0) {
> - if (a->bo_id[i] == b->bo_id[i])
> - continue;
> - else if (a->bo_id[i] < b->bo_id[i]) {
> - /* b is a successor of a */
> - return (1);
> - } else {
> - /* b is a predecessor of a */
> - return (-1);
> - }
> - } else if (b->bo_id[i] != 0) {
> - /* b is larger, but a child of a */
> - return (2);
> - } else
> - break;
> - }
> -
> - /* b and a are identical */
> - return (0);
> }
> Index: usr.sbin/ypldap/ber.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/ypldap/ber.c,v
> retrieving revision 1.26
> diff -u -p -r1.26 ber.c
> --- usr.sbin/ypldap/ber.c 13 Jul 2018 08:50:38 -0000 1.26
> +++ usr.sbin/ypldap/ber.c 30 Jul 2018 20:22:54 -0000
> @@ -430,6 +430,32 @@ ber_string2oid(const char *oidstr, struc
> return (0);
> }
>
> +int
> +ber_oid_cmp(struct ber_oid *a, struct ber_oid *b)
> +{
> + size_t i;
> + for (i = 0; i < BER_MAX_OID_LEN; i++) {
> + if (a->bo_id[i] != 0) {
> + if (a->bo_id[i] == b->bo_id[i])
> + continue;
> + else if (a->bo_id[i] < b->bo_id[i]) {
> + /* b is a successor of a */
> + return (1);
> + } else {
> + /* b is a predecessor of a */
> + return (-1);
> + }
> + } else if (b->bo_id[i] != 0) {
> + /* b is larger, but a child of a */
> + return (2);
> + } else
> + break;
> + }
> +
> + /* b and a are identical */
> + return (0);
> +}
> +
> struct ber_element *
> ber_add_oid(struct ber_element *prev, struct ber_oid *o)
> {
> @@ -756,6 +782,15 @@ ber_scanf_elements(struct ber_element *b
>
> }
>
> +ssize_t
> +ber_get_writebuf(struct ber *b, void **buf)
> +{
> + if (b->br_wbuf == NULL)
> + return -1;
> + *buf = b->br_wbuf;
> + return (b->br_wend - b->br_wbuf);
> +}
> +
> /*
> * write ber elements to the write buffer
> *
> @@ -795,6 +830,13 @@ ber_write_elements(struct ber *ber, stru
> return (len);
> }
>
> +void
> +ber_set_readbuf(struct ber *b, void *buf, size_t len)
> +{
> + b->br_rbuf = b->br_rptr = buf;
> + b->br_rend = (u_int8_t *)buf + len;
> +}
> +
> /*
> * read ber elements from the read buffer
> *
> @@ -896,6 +938,26 @@ ber_calc_len(struct ber_element *root)
> return (root->be_len + size);
> }
>
> +void
> +ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *))
> +{
> + b->br_application = cb;
> +}
> +
> +void
> +ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t),
> + void *arg)
> +{
> + elm->be_cb = cb;
> + elm->be_cbarg = arg;
> +}
> +
> +void
> +ber_free(struct ber *b)
> +{
> + free(b->br_wbuf);
> +}
> +
> /*
> * internal functions
> */
> @@ -1204,42 +1266,6 @@ ber_read_element(struct ber *ber, struct
> return totlen;
> }
>
> -void
> -ber_set_readbuf(struct ber *b, void *buf, size_t len)
> -{
> - b->br_rbuf = b->br_rptr = buf;
> - b->br_rend = (u_int8_t *)buf + len;
> -}
> -
> -ssize_t
> -ber_get_writebuf(struct ber *b, void **buf)
> -{
> - if (b->br_wbuf == NULL)
> - return -1;
> - *buf = b->br_wbuf;
> - return (b->br_wend - b->br_wbuf);
> -}
> -
> -void
> -ber_set_application(struct ber *b, unsigned long (*cb)(struct ber_element *))
> -{
> - b->br_application = cb;
> -}
> -
> -void
> -ber_set_writecallback(struct ber_element *elm, void (*cb)(void *, size_t),
> - void *arg)
> -{
> - elm->be_cb = cb;
> - elm->be_cbarg = arg;
> -}
> -
> -void
> -ber_free(struct ber *b)
> -{
> - free(b->br_wbuf);
> -}
> -
> static ssize_t
> ber_getc(struct ber *b, u_char *c)
> {
> @@ -1265,30 +1291,4 @@ ber_read(struct ber *ber, void *buf, siz
> ber->br_offs += len;
>
> return len;
> -}
> -
> -int
> -ber_oid_cmp(struct ber_oid *a, struct ber_oid *b)
> -{
> - size_t i;
> - for (i = 0; i < BER_MAX_OID_LEN; i++) {
> - if (a->bo_id[i] != 0) {
> - if (a->bo_id[i] == b->bo_id[i])
> - continue;
> - else if (a->bo_id[i] < b->bo_id[i]) {
> - /* b is a successor of a */
> - return (1);
> - } else {
> - /* b is a predecessor of a */
> - return (-1);
> - }
> - } else if (b->bo_id[i] != 0) {
> - /* b is larger, but a child of a */
> - return (2);
> - } else
> - break;
> - }
> -
> - /* b and a are identical */
> - return (0);
> }
>
--
:wq Claudio