2181
2180
if (maxresponses == 0)
2182
2181
maxresponses = 100; /* more than reasonable default */
2183
/* ensure that the total number of responses fits in a mallocable
2186
if (maxresponses < 0 ||
2187
maxresponses > INT_MAX / sizeof(struct varbind_list *))
2188
maxresponses = INT_MAX / sizeof(struct varbind_list *);
2190
/* ensure that the maximum number of repetitions will fit in the
2193
if (maxbulk <= 0 || maxbulk > maxresponses / r)
2194
maxbulk = maxresponses / r;
2187
2196
/* limit getbulk number of repeats to a configured size */
2188
if (asp->pdu->errindex > maxbulk && maxbulk != -1) {
2197
if (asp->pdu->errindex > maxbulk) {
2189
2198
asp->pdu->errindex = maxbulk;
2192
numresponses = asp->pdu->errindex * r;
2194
/* limit getbulk number of getbulk responses to a configured size */
2195
if (maxresponses != -1 && numresponses > maxresponses) {
2196
/* attempt to truncate this */
2197
asp->pdu->errindex = maxresponses/r;
2198
numresponses = asp->pdu->errindex * r;
2199
DEBUGMSGTL(("snmp_agent", "truncating number of getbulk repeats to %d\n", asp->pdu->errindex));
2199
DEBUGMSGTL(("snmp_agent",
2200
"truncating number of getbulk repeats to %d\n",
2201
asp->pdu->errindex));
2202
2204
asp->bulkcache =
2203
(netsnmp_variable_list **) malloc(numresponses *
2205
(netsnmp_variable_list **) malloc(
2206
asp->pdu->errindex * r * sizeof(struct varbind_list *));
2206
2208
if (!asp->bulkcache) {
2207
2209
DEBUGMSGTL(("snmp_agent", "Bulkcache malloc failed\n"));
2208
2210
return SNMP_ERR_GENERR;
2300
2302
case SNMP_MSG_SET:
2301
2303
view = in_a_view(varbind_ptr->name, &varbind_ptr->name_length,
2302
2304
asp->pdu, varbind_ptr->type);
2303
if (view != VACM_SUCCESS)
2305
if (view != VACM_SUCCESS) {
2306
asp->index = vbcount;
2304
2307
return SNMP_ERR_NOACCESS;
2307
2311
case SNMP_MSG_GETNEXT: