ggsn_vty.c: Fix wrong use of in46a_from_eua, print IPv6 euas

in46a_from_eua() API documentation clearly states an array of 2 items
should be passed as pointer, but show_one_pdp() was passing only one,
which would end up in out-of-bounds writes on v4v6 EUAs.

Let's better use ippool to print allocated ip addresses instead of
parsing EUAs we sent some point in the past.

Related OS#4154
Change-Id: Ia34939957bb7856388cb52a741cec0c015a08c70
This commit is contained in:
Pau Espin 2019-08-20 12:23:14 +02:00
parent 95cd897c3f
commit 03cce86941
1 changed files with 7 additions and 3 deletions

View File

@ -734,7 +734,7 @@ static const char *print_gsnaddr(const struct ul16_t *in)
static void show_one_pdp(struct vty *vty, struct pdp_t *pdp)
{
struct in46_addr eua46;
struct ippoolm_t *peer;
char name_buf[256];
char *apn_name;
int rc;
@ -757,8 +757,12 @@ static void show_one_pdp(struct vty *vty, struct pdp_t *pdp)
apn_name = osmo_apn_to_str(name_buf, pdp->apn_use.v, pdp->apn_use.l);
vty_out(vty, " APN in use: %s%s", apn_name ? name_buf : "(NONE)", VTY_NEWLINE);
in46a_from_eua(&pdp->eua, &eua46);
vty_out(vty, " End-User Address: %s%s", in46a_ntoa(&eua46), VTY_NEWLINE);
if ((peer = pdp_get_peer_ipv(pdp, false)))
vty_out(vty, " End-User Address (IPv4): %s%s",
in46a_ntop(&peer->addr, name_buf, sizeof(name_buf)), VTY_NEWLINE);
if ((peer = pdp_get_peer_ipv(pdp, true)))
vty_out(vty, " End-User Address (IPv6): %s%s",
in46a_ntop(&peer->addr, name_buf, sizeof(name_buf)), VTY_NEWLINE);
vty_out(vty, " Transmit GTP Sequence Number for G-PDU: %s%s",
pdp->tx_gpdu_seq ? "Yes" : "No", VTY_NEWLINE);
}