The warning was:
./print-bgp.c: In function 'bgp_vpn_rd_print':
./print-bgp.c:797:65: warning: '%u' directive output may be truncated
writing between 1 and 3 bytes into a region of size between 2 and 31
[-Wformat-truncation=]
797 | snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
| ^~
./print-bgp.c:797:48: note: directive argument in the range [0, 255]
797 | snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
| ^~~~~~~~~~~~~~~~~~~~~~~~
./print-bgp.c:797:48: note: directive argument in the range [0, 65535]
./print-bgp.c:797:9: note: 'snprintf' output between 15 and 50 bytes
into a destination of size 41
797 | snprintf(pos, sizeof(rd) - (pos - rd), "%s:%u (%u.%u.%u.%u:%u)",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
798 | as_printf(ndo, astostr, sizeof(astostr), GET_BE_U_4(pptr + 2)),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
799 | GET_BE_U_2(pptr + 6), GET_U_1(pptr + 2),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
800 | GET_U_1(pptr + 3), GET_U_1(pptr + 4),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
801 | GET_U_1(pptr + 5), GET_BE_U_2(pptr + 6));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{ 0, NULL },
};
-static char astostr[20];
+/* allocate space for the largest possible string */
+static char astostr[sizeof("xxxxx.xxxxx")];
/*
* as_printf
const u_char *pptr)
{
/* allocate space for the largest possible string */
- static char rd[sizeof("xxxxxxxxxx:xxxxx (xxx.xxx.xxx.xxx:xxxxx)")];
+ static char rd[sizeof("xxxxx.xxxxx:xxxxx (xxx.xxx.xxx.xxx:xxxxx)")];
char *pos = rd;
/* ok lets load the RD format */