gtphub: fix three oversights (thanks to coverity).

- an unnecessary if-not-NULL check (1339764);
- a missing nul termination safety net (1339768);
- a typo resulting in the wrong proxy being logged (1339767).

Sponsored-by: On-Waves ehi
This commit is contained in:
Neels Hofmeyr 2015-11-17 12:28:09 +01:00
parent 3d3aa8fb88
commit 3c820ee532
1 changed files with 3 additions and 5 deletions

View File

@ -1223,10 +1223,7 @@ static int gtphub_write(const struct osmo_fd *to,
errno = 0;
ssize_t sent = sendto(to->fd, buf, buf_len, 0,
(struct sockaddr*)&to_addr->a, to_addr->l);
if (to_addr) {
LOG(LOGL_DEBUG, "to %s\n", osmo_sockaddr_to_str(to_addr));
}
LOG(LOGL_DEBUG, "to %s\n", osmo_sockaddr_to_str(to_addr));
if (sent == -1) {
LOG(LOGL_ERROR, "error: %s\n", strerror(errno));
@ -1712,6 +1709,7 @@ void gtphub_resolved_ggsn(struct gtphub *hub, const char *apn_oi_str,
gtphub_port_ref_count_inc(pp);
strncpy(ggsn->apn_oi_str, apn_oi_str, sizeof(ggsn->apn_oi_str));
ggsn->apn_oi_str[sizeof(ggsn->apn_oi_str) - 1] = '\0';
ggsn->expiry_entry.del_cb = resolved_gssn_del_cb;
expiry_add(&hub->expire_tei_maps, &ggsn->expiry_entry, now);
@ -1902,7 +1900,7 @@ int gtphub_start(struct gtphub *hub, struct gtphub_cfg *cfg)
}
for (plane_idx = 0; plane_idx < GTPH_PLANE_N; plane_idx++) {
if (hub->sgsn_proxy[plane_idx])
if (hub->ggsn_proxy[plane_idx])
LOG(LOGL_NOTICE, "Using GGSN %s proxy %s\n",
gtphub_plane_idx_names[plane_idx],
gtphub_port_str(hub->ggsn_proxy[plane_idx]));