Apply revisions 1.4 and 1.5 from ldapd's ber.c to ypldap's copy, so it can

deal with messages that haven't been fully read from the server yet.

Obtained from:	OpenBSD r1.11
This commit is contained in:
Marcelo Araujo 2016-04-13 01:54:33 +00:00
parent d13c461400
commit 0e3562425e

View File

@ -1083,6 +1083,15 @@ ber_read_element(struct ber *ber, struct ber_element *elm)
DPRINTF("ber read element size %zd\n", len);
totlen += r + len;
/*
* If using an external buffer and the total size of the element
* is larger, then the external buffer don't bother to continue.
*/
if (ber->fd == -1 && len > ber->br_rend - ber->br_rptr) {
errno = ECANCELED;
return -1;
}
elm->be_type = type;
elm->be_len = len;
elm->be_class = class;