travelping / upg-vpp

User Plane Gateway (UPG) based on VPP
Apache License 2.0
148 stars 51 forks source link

format_user_id function error #349

Open Patjwi opened 1 year ago

Patjwi commented 1 year ago

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.

james-gogo commented 1 year ago

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; }