This includes some memory leaks when decoding erroneous LLDP TLV.
lldpctl_atom_t *neighbor,
void *data)
{
- int ch, i;
+ int i;
struct cbargs *args = data;
optind = 0;
- while ((ch = getopt(args->argc, args->argv, LLDPCTL_ARGS)) != -1);
+ while (getopt(args->argc, args->argv, LLDPCTL_ARGS) != -1);
if (optind < args->argc) {
for (i = optind; i < args->argc; i++)
if (strcmp(args->argv[i],
result = malloc( sizeof( struct writer ) );
if ( ! result ) {
fatalx("out of memory");
+ free(priv);
return NULL;
}
void *t, struct marshal_info *mi)
{
struct hmsg_header hdr;
- size_t len = 0, newlen;
+ ssize_t len = 0, newlen;
void *buffer = NULL;
log_debug("control", "send a message through control socket");
free(name);
if (output_len <= 0) {
*type = NONE;
- free(name);
return 0;
}
return output_len;
log_debug("rpc", "handle client request");
for (ch = client_handles; ch->handle != NULL; ch++) {
if (ch->type == type) {
- answer = NULL; len = 0;
+ answer = NULL;
len = ch->handle(cfg, &type, buffer, n, &answer,
subscribed);
sent = send(out, type, answer, len);
struct lldpd_hardware *hardware,
int fd, char *buffer, size_t size)
{
- int n;
struct bpf_buffer *bpfbuf = hardware->h_data;
struct bpf_hdr *bh;
log_debug("interfaces", "receive PDU from ethernet device %s",
/* We assume we have only receive one packet (unbuffered mode). Dunno if
* this is correct. */
- if ((n = read(fd, bpfbuf->data, bpfbuf->len)) == -1) {
+ if (read(fd, bpfbuf->data, bpfbuf->len) == -1) {
log_warn("interfaces", "error while receiving frame on %s",
hardware->h_ifname);
hardware->h_rx_discarded_cnt++;
{
struct lldpd_hardware *hardware;
struct interfaces_device *iface;
- struct interfaces_device_list *interfaces = NULL;
- struct interfaces_address_list *addresses = NULL;
+ struct interfaces_device_list *interfaces;
+ struct interfaces_address_list *addresses;
struct ifaddrs *ifaddrs = NULL, *ifaddr;
interfaces = malloc(sizeof(struct interfaces_device_list));
interfaces_update(struct lldpd *cfg)
{
struct lldpd_hardware *hardware;
- struct interfaces_device_list *interfaces = NULL;
- struct interfaces_address_list *addresses = NULL;
+ struct interfaces_device_list *interfaces;
+ struct interfaces_address_list *addresses;
interfaces = netlink_get_interfaces();
addresses = netlink_get_addresses();
if (interfaces == NULL || addresses == NULL) {
log_warn("lldp", "unable to alloc vlan name for "
"tlv received on %s",
hardware->h_ifname);
+ free(vlan);
goto malformed;
}
PEEK_BYTES(vlan->v_name, vlan_len);
log_warn("lldp", "unable to alloc pid name for "
"tlv received on %s",
hardware->h_ifname);
+ free(pi);
goto malformed;
}
PEEK_BYTES(pi->p_pi, pi->p_pi_len);
lldpd_decode(struct lldpd *cfg, char *frame, int s,
struct lldpd_hardware *hardware)
{
- int i, result;
+ int i;
struct lldpd_chassis *chassis, *ochassis = NULL;
struct lldpd_port *port, *oport = NULL, *aport;
int guess = LLDPD_MODE_LLDP;
if (cfg->g_protocols[i].mode == guess) {
log_debug("decode", "using decode function for %s protocol",
cfg->g_protocols[i].name);
- if ((result = cfg->g_protocols[i].decode(cfg, frame,
- s, hardware, &chassis, &port)) == -1) {
+ if (cfg->g_protocols[i].decode(cfg, frame,
+ s, hardware, &chassis, &port) == -1) {
log_debug("decode", "function for %s protocol did not decode this frame",
cfg->g_protocols[i].name);
return;
static int
netlink_connect(int protocol)
{
- int s = 0;
+ int s;
struct sockaddr_nl local = {
.nl_family = AF_NETLINK,
.nl_pid = getpid(),
priv_exit()
{
int status;
- int rc;
- if ((rc = waitpid(monitored, &status, WNOHANG)) == 0) {
+ if (waitpid(monitored, &status, WNOHANG) == 0) {
log_debug("privsep", "killing child");
kill(monitored, SIGTERM);
}
- if ((rc = waitpid(monitored, &status, WNOHANG)) == -1)
+ if (waitpid(monitored, &status, WNOHANG) == -1)
_exit(0);
log_debug("privsep", "waiting for child %d to terminate", monitored);
}
TAILQ_HEAD(ref_l, ref);
/* Serialize the given object. */
-size_t
+ssize_t
marshal_serialize_(struct marshal_info *mi, void *unserialized, void **input,
int skip, void *_refs, int osize)
{
MARSHAL_END
/* Serialization */
-size_t marshal_serialize_(struct marshal_info *, void *, void **, int, void *, int);
+ssize_t marshal_serialize_(struct marshal_info *, void *, void **, int, void *, int);
#define marshal_serialize(type, o, output) marshal_serialize_(&MARSHAL_INFO(type), o, output, 0, NULL, 0)
/* Unserialization */