~ubuntu-branches/ubuntu/wily/net-snmp/wily-proposed

« back to all changes in this revision

Viewing changes to agent/snmp_agent.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-28 14:59:36 UTC
  • mfrom: (1.2.3 upstream) (1.1.12 sid)
  • Revision ID: james.westby@ubuntu.com-20100628145936-cbiallic69pn044g
Tags: 5.4.3~dfsg-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Set Ubuntu maintainer address.
  - net-snmp-config: Use bash. (LP: #104738)
  - Removed multiuser option when calling update-rc.d. (LP: #254261)
  - debian/snmpd.init: LSBify the init script.
  - debian/patches/52_fix_snmpcmd_1_typo.patch: Adjust a typo in snmpcmd.1
    (LP: #250459)
  - debian/snmpd.postinst: source debconf before doing work, LP: #589056
  - debian/snmp.preinst, debian/snmp.prerm: kill any/all processes owned by
    snmp user before install/uninstall, LP: #573391
  - Add apport hook (LP: #533603):
  - debian/{snmp,snmpd}.apport: Added.
  - debian/control: Build-depends on dh-apport.
  - debian/rules: 
    + Add --with apport.
    + override_dh_apport to install hook on snmpd package only.
 * Dropped patches:
   - debian/patches/99-fix-ubuntu-div0.patch: Fix dvision by zero.. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
644
644
    }
645
645
}
646
646
 
 
647
void netsnmp_addrcache_destroy(void)
 
648
{
 
649
    int             i = 0;
 
650
 
 
651
    for (i = 0; i < SNMP_ADDRCACHE_SIZE; i++) {
 
652
        if (addrCache[i].status == SNMP_ADDRCACHE_USED) {
 
653
            free(addrCache[i].addr);
 
654
            addrCache[i].status = SNMP_ADDRCACHE_UNUSED;
 
655
        }
 
656
    }
 
657
}
 
658
 
647
659
/*
648
660
 * Adds a new entry to the cache of addresses that
649
661
 * have recently made connections to the agent.
1153
1165
{
1154
1166
    netsnmp_transport *transport;
1155
1167
    char           *cptr;
1156
 
    char            buf[SPRINT_MAX_LEN];
 
1168
    char           *buf = NULL;
1157
1169
    char           *st;
1158
1170
 
1159
1171
    /* default to a default cache size */
1168
1180
        
1169
1181
        return 0;               /*  No error if ! MASTER_AGENT  */
1170
1182
    }
1171
 
#ifdef USING_AGENTX_MASTER_MODULE
1172
 
    if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, 
1173
 
                               NETSNMP_DS_AGENT_AGENTX_MASTER) == 1)
1174
 
        real_init_master();
1175
 
#endif
1176
 
#ifdef USING_SMUX_MODULE
1177
 
    if(should_init("smux"))
1178
 
    real_init_smux();
1179
 
#endif
1180
1183
 
1181
1184
    /*
1182
1185
     * Have specific agent ports been specified?  
1185
1188
                                 NETSNMP_DS_AGENT_PORTS);
1186
1189
 
1187
1190
    if (cptr) {
1188
 
        snprintf(buf, sizeof(buf), "%s", cptr);
1189
 
        buf[ sizeof(buf)-1 ] = 0;
 
1191
        buf = strdup(cptr);
 
1192
        if (!buf) {
 
1193
            snmp_log(LOG_ERR,
 
1194
                     "Error processing transport \"%s\"\n", cptr);
 
1195
            return 1;
 
1196
        }
1190
1197
    } else {
1191
1198
        /*
1192
1199
         * No, so just specify the default port.  
1193
1200
         */
1194
 
        buf[0] = 0;
 
1201
        buf = "";
1195
1202
    }
1196
1203
 
1197
1204
    DEBUGMSGTL(("snmp_agent", "final port spec: \"%s\"\n", buf));
1221
1228
            DEBUGMSGTL(("snmp_agent",
1222
1229
                        "init_master_agent; pseudo-transport \"none\" "
1223
1230
                        "requested\n"));
1224
 
            return 0;
 
1231
            break;
1225
1232
        }
1226
1233
        transport = netsnmp_transport_open_server("snmp", cptr);
1227
1234
 
1243
1250
        }
1244
1251
    } while(st && *st != '\0');
1245
1252
 
 
1253
#ifdef USING_AGENTX_MASTER_MODULE
 
1254
    if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, 
 
1255
                               NETSNMP_DS_AGENT_AGENTX_MASTER) == 1)
 
1256
        real_init_master();
 
1257
#endif
 
1258
#ifdef USING_SMUX_MODULE
 
1259
    if(should_init("smux"))
 
1260
    real_init_smux();
 
1261
#endif
 
1262
 
1246
1263
    return 0;
1247
1264
}
1248
1265
 
2203
2220
 
2204
2221
            asp->bulkcache =
2205
2222
                (netsnmp_variable_list **) malloc(
2206
 
                    asp->pdu->errindex * r * sizeof(struct varbind_list *));
 
2223
                    (n + asp->pdu->errindex * r) * sizeof(struct varbind_list *));
2207
2224
 
2208
2225
            if (!asp->bulkcache) {
2209
2226
                DEBUGMSGTL(("snmp_agent", "Bulkcache malloc failed\n"));