Try to fix compile warning in mdns.c

src/apps/mdns/mdns.c: In function 'mdns_debug_print_answer':
src/apps/mdns/mdns.c:796:24: warning: ', rdata = ' directive output may be truncated writing 10 bytes into a region of size between 8 and 15 [-Wformat-truncation=]
   snprintf(string, 35, "Type = %2d, class = %1d, rdata = ", a->info.type, a->info.klass);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/apps/mdns/mdns.c:796:3: note: 'snprintf' output between 31 and 38 bytes into a destination of size 35
   snprintf(string, 35, "Type = %2d, class = %1d, rdata = ", a->info.type, a->info.klass);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:
Dirk Ziegelmeier 2018-11-22 11:37:24 +01:00
parent 10e0130a4a
commit c23aa713f9

View File

@ -788,16 +788,22 @@ mdns_convert_out_to_in_pkt(struct mdns_packet *inpkt, struct mdns_outpacket *out
static void static void
mdns_debug_print_answer(struct mdns_packet *pkt, struct mdns_answer *a) mdns_debug_print_answer(struct mdns_packet *pkt, struct mdns_answer *a)
{ {
#ifdef LWIP_DEBUG
/* Arbitratry chose for 200 -> don't want to see more then that. It's only /* Arbitratry chose for 200 -> don't want to see more then that. It's only
* for debug so not that important. */ * for debug so not that important. */
char string[200]; char string[200];
int i; int i;
int pos;
snprintf(string, 35, "Type = %2d, class = %1d, rdata = ", a->info.type, a->info.klass); pos = snprintf(string, sizeof(string), "Type = %2d, class = %1d, rdata = ", a->info.type, a->info.klass);
for (i = 0; ((i < a->rd_length) && ((30 + 4*i) < 195)) ; i++) { for (i = 0; ((i < a->rd_length) && ((pos + 4*i) < 195)) ; i++) {
snprintf(&string[30 + 4*i], 5, "%3d ", (u8_t)pbuf_get_at(pkt->pbuf, (u16_t)(a->rd_offset + i))); snprintf(&string[pos + 4*i], 5, "%3d ", (u8_t)pbuf_get_at(pkt->pbuf, (u16_t)(a->rd_offset + i)));
} }
LWIP_DEBUGF(MDNS_DEBUG, ("MDNS: %s\n", string)); LWIP_DEBUGF(MDNS_DEBUG, ("MDNS: %s\n", string));
#else
LWIP_UNUSED_ARG(pkt);
LWIP_UNUSED_ARG(a);
#endif
} }
/** /**