and not the start of it. Fixes getbulk requests for multiple OIDs.
From Gerhard Roth, ok blambert@
-/* $OpenBSD: mps.c,v 1.21 2015/07/18 16:54:43 blambert Exp $ */
+/* $OpenBSD: mps.c,v 1.22 2015/10/08 08:17:30 sthen Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
int
mps_getbulkreq(struct snmp_message *msg, struct ber_element **root,
- struct ber_oid *o, int max)
+ struct ber_element **end, struct ber_oid *o, int max)
{
struct ber_element *c, *d, *e;
size_t len;
j = max;
c = *root;
+ *end = NULL;
for (d = NULL, len = 0; j > 0; j--) {
e = ber_add_sequence(NULL);
if (c == NULL)
c = e;
ret = mps_getnextreq(msg, e, o);
- if (ret == 1)
+ if (ret == 1) {
+ *root = c;
return (1);
+ }
if (ret == -1) {
ber_free_elements(e);
if (d == NULL)
if (d != NULL)
ber_link_elements(d, e);
d = e;
+ *end = d;
}
*root = c;
-/* $OpenBSD: snmpd.h,v 1.61 2015/10/05 15:29:14 uebayasi Exp $ */
+/* $OpenBSD: snmpd.h,v 1.62 2015/10/08 08:17:30 sthen Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
struct ber_element *sm_c;
struct ber_element *sm_next;
struct ber_element *sm_last;
+ struct ber_element *sm_end;
u_int8_t sm_data[READ_BUF_SIZE];
size_t sm_datalen;
int mps_getnextreq(struct snmp_message *, struct ber_element *,
struct ber_oid *);
int mps_getbulkreq(struct snmp_message *, struct ber_element **,
- struct ber_oid *, int);
+ struct ber_element **, struct ber_oid *, int);
int mps_setreq(struct snmp_message *, struct ber_element *,
struct ber_oid *);
int mps_set(struct ber_oid *, void *, long long);
-/* $OpenBSD: snmpe.c,v 1.40 2015/01/16 00:05:13 deraadt Exp $ */
+/* $OpenBSD: snmpe.c,v 1.41 2015/10/08 08:17:30 sthen Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
break;
case 1:
msg->sm_c = NULL;
+ msg->sm_end = NULL;
switch (msg->sm_context) {
case SNMP_C_GETBULKREQ:
ret = mps_getbulkreq(msg, &msg->sm_c,
- &o, msg->sm_maxrepetitions);
+ &msg->sm_end, &o,
+ msg->sm_maxrepetitions);
if (ret == 0 || ret == 1)
break;
msg->sm_error = SNMP_ERROR_NOSUCHNAME;
}
if (msg->sm_c == NULL)
break;
+ if (msg->sm_end == NULL)
+ msg->sm_end = msg->sm_c;
if (msg->sm_last == NULL)
msg->sm_varbindresp = msg->sm_c;
else
ber_link_elements(msg->sm_last, msg->sm_c);
- msg->sm_last = msg->sm_c;
+ msg->sm_last = msg->sm_end;
break;
}
}