MFC r294507,r294567,r299466:
r294507 (by harti): Fill the ifAlias leaf of the ifXTable with the interface description if there is one available and it fits into the maximum size (64 characters). r294567 (by bz): Change the variable to a #define in order to make gcc happy which otherwise will complain about "variably modified 'alias' at file scope". Unbreaks the build on gcc platforms. r299466 (by cem): bsnmpd: Fix size of trapsink::comm to match other community arrays This fixes a number of possible strcpy() buffer overruns between the various community strings in trap.c. CIDs: 1006820, 1006821, 1006822
This commit is contained in:
parent
f9fe5ac105
commit
4ac51bf54b
@ -443,6 +443,7 @@ mib_fetch_ifmib(struct mibif *ifp)
|
|||||||
size_t len;
|
size_t len;
|
||||||
void *newmib;
|
void *newmib;
|
||||||
struct ifmibdata oldmib = ifp->mib;
|
struct ifmibdata oldmib = ifp->mib;
|
||||||
|
struct ifreq irr;
|
||||||
|
|
||||||
if (fetch_generic_mib(ifp, &oldmib) == -1)
|
if (fetch_generic_mib(ifp, &oldmib) == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -514,6 +515,18 @@ mib_fetch_ifmib(struct mibif *ifp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
strncpy(irr.ifr_name, ifp->name, sizeof(irr.ifr_name));
|
||||||
|
irr.ifr_buffer.buffer = MIBIF_PRIV(ifp)->alias;
|
||||||
|
irr.ifr_buffer.length = sizeof(MIBIF_PRIV(ifp)->alias);
|
||||||
|
if (ioctl(mib_netsock, SIOCGIFDESCR, &irr) == -1) {
|
||||||
|
MIBIF_PRIV(ifp)->alias[0] = 0;
|
||||||
|
if (errno != ENOMSG)
|
||||||
|
syslog(LOG_WARNING, "SIOCGIFDESCR (%s): %m", ifp->name);
|
||||||
|
} else if (irr.ifr_buffer.buffer == NULL) {
|
||||||
|
MIBIF_PRIV(ifp)->alias[0] = 0;
|
||||||
|
syslog(LOG_WARNING, "SIOCGIFDESCR (%s): too long (%zu)",
|
||||||
|
ifp->name, irr.ifr_buffer.length);
|
||||||
|
}
|
||||||
ifp->mibtick = get_ticks();
|
ifp->mibtick = get_ticks();
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,9 @@
|
|||||||
#include "snmp_mibII.h"
|
#include "snmp_mibII.h"
|
||||||
#include "mibII_tree.h"
|
#include "mibII_tree.h"
|
||||||
|
|
||||||
|
/* maximum size of the interface alias */
|
||||||
|
#define MIBIF_ALIAS_SIZE (64 + 1)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Interface list and flags.
|
* Interface list and flags.
|
||||||
*/
|
*/
|
||||||
@ -77,6 +80,9 @@ struct mibif_private {
|
|||||||
uint64_t hc_opackets;
|
uint64_t hc_opackets;
|
||||||
uint64_t hc_imcasts;
|
uint64_t hc_imcasts;
|
||||||
uint64_t hc_ipackets;
|
uint64_t hc_ipackets;
|
||||||
|
|
||||||
|
/* this should be made public */
|
||||||
|
char alias[MIBIF_ALIAS_SIZE];
|
||||||
};
|
};
|
||||||
#define MIBIF_PRIV(IFP) ((struct mibif_private *)((IFP)->private))
|
#define MIBIF_PRIV(IFP) ((struct mibif_private *)((IFP)->private))
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ op_ifxtable(struct snmp_context *ctx, struct snmp_value *value,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LEAF_ifAlias:
|
case LEAF_ifAlias:
|
||||||
ret = string_get(value, "", -1);
|
ret = string_get(value, MIBIF_PRIV(ifp)->alias, -1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LEAF_ifCounterDiscontinuityTime:
|
case LEAF_ifCounterDiscontinuityTime:
|
||||||
|
@ -307,7 +307,7 @@ struct trapsink {
|
|||||||
struct asn_oid index;
|
struct asn_oid index;
|
||||||
u_int status;
|
u_int status;
|
||||||
int socket;
|
int socket;
|
||||||
u_char comm[SNMP_COMMUNITY_MAXLEN];
|
u_char comm[SNMP_COMMUNITY_MAXLEN + 1];
|
||||||
int version;
|
int version;
|
||||||
};
|
};
|
||||||
enum {
|
enum {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user