travelping/upg-vpp

format_user_id function error

Patjwi opened this issue · 1 comments

Patjwi commented

There is a bug in the format_user_id function in the upf/pfcp.c.
This causes a segmentation fault error when running in debug mode. This problem started occurring from stable/1.6.

image

In my opinion, the code can be fixed by modifying it so that the s0 pointer variable is provided as a parameter to the format function in the first if statement. Please refer to stable/1.4.

I think it would be correct to change it to s0 for IMSI and s for IMEI.

u8 *
format_user_id (u8 * s0, va_list * args)
{
pfcp_user_id_t *v = va_arg (*args, pfcp_user_id_t *);
u8 *s = s0;

if (v->imsi_len > 0)
s = format (s0, "IMSI:%U,", format_tbcd, v->imsi, v->imsi_len); // s --> s0
if (v->imei_len > 0)
s = format (s, "IMEI:%U,", format_tbcd, v->imei, v->imei_len); // s0 --> s
if (v->msisdn_len > 0)
s = format (s, "MSISDN:%U,", format_tbcd, v->msisdn, v->msisdn_len);
if (vec_len (v->nai) > 0)
s = format (s, "NAI:%v,", v->nai);

if (s != s0)
_vec_len (s)--;

return s;
}