~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to agent/snmp_agent.c

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Friedrich
  • Date: 2009-11-12 16:17:40 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20091112161740-t2xvix834vmtxa9f
Tags: upstream-5.4.2.1~dfsg
ImportĀ upstreamĀ versionĀ 5.4.2.1~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
2170
2170
            r = 0;
2171
2171
            asp->bulkcache = NULL;
2172
2172
        } else {
2173
 
            int numresponses;
2174
2173
            int           maxbulk =
2175
2174
                netsnmp_ds_get_int(NETSNMP_DS_APPLICATION_ID,
2176
2175
                                   NETSNMP_DS_AGENT_MAX_GETBULKREPEATS);
2181
2180
            if (maxresponses == 0)
2182
2181
                maxresponses = 100;   /* more than reasonable default */
2183
2182
 
2184
 
            if (maxbulk == 0)
2185
 
                maxbulk = -1;
 
2183
            /* ensure that the total number of responses fits in a mallocable
 
2184
             * result vector
 
2185
             */
 
2186
            if (maxresponses < 0 ||
 
2187
                maxresponses > INT_MAX / sizeof(struct varbind_list *))
 
2188
                maxresponses = INT_MAX / sizeof(struct varbind_list *);
 
2189
 
 
2190
            /* ensure that the maximum number of repetitions will fit in the
 
2191
             * result vector
 
2192
             */
 
2193
            if (maxbulk <= 0 || maxbulk > maxresponses / r)
 
2194
                maxbulk = maxresponses / r;
2186
2195
 
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;
2190
 
            }
2191
 
 
2192
 
            numresponses = asp->pdu->errindex * r;
2193
 
 
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));
2200
2202
            }
2201
2203
 
2202
2204
            asp->bulkcache =
2203
 
                (netsnmp_variable_list **) malloc(numresponses *
2204
 
                                                  sizeof(struct
2205
 
                                                         varbind_list *));
 
2205
                (netsnmp_variable_list **) malloc(
 
2206
                    asp->pdu->errindex * r * sizeof(struct varbind_list *));
 
2207
 
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;
 
2308
            }
2305
2309
            break;
2306
2310
 
2307
2311
        case SNMP_MSG_GETNEXT: