From: Sean Bright Date: Fri, 19 Aug 2022 16:02:07 +0000 (-0400) Subject: chan_dahdi.c: Resolve a format-truncation build warning. X-Git-Tag: 19.7.0-rc1~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddc6d1f796fab335ebeed0843200e3b06608782a;p=thirdparty%2Fasterisk.git chan_dahdi.c: Resolve a format-truncation build warning. With gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0: > chan_dahdi.c:4129:18: error: ā€˜%s’ directive output may be truncated > writing up to 255 bytes into a region of size between 242 and 252 > [-Werror=format-truncation=] This removes the error-prone sizeof(...) calculations in favor of just doubling the size of the base buffer. Change-Id: I2d276785286730d3d5d0a921bcea2e065dbf27c5 --- diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 8ce0526f4d..b829aa43f4 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -4115,7 +4115,7 @@ static void dahdi_r2_on_context_log(openr2_context_t *r2context, openr2_log_leve { #define CONTEXT_TAG "Context - " char logmsg[256]; - char completemsg[sizeof(logmsg) + sizeof(CONTEXT_TAG) - 1]; + char completemsg[sizeof(logmsg) * 2]; vsnprintf(logmsg, sizeof(logmsg), fmt, ap); snprintf(completemsg, sizeof(completemsg), CONTEXT_TAG "%s", logmsg); dahdi_r2_write_log(level, completemsg); @@ -4128,10 +4128,11 @@ static void dahdi_r2_on_chan_log(openr2_chan_t *r2chan, openr2_log_level_t level { #define CHAN_TAG "Chan " char logmsg[256]; - char completemsg[sizeof(logmsg) + sizeof(CHAN_TAG) - 1]; + char completemsg[sizeof(logmsg) * 2]; vsnprintf(logmsg, sizeof(logmsg), fmt, ap); snprintf(completemsg, sizeof(completemsg), CHAN_TAG "%d - %s", openr2_chan_get_number(r2chan), logmsg); dahdi_r2_write_log(level, completemsg); +#undef CHAN_TAG } static int dahdi_r2_on_dnis_digit_received(openr2_chan_t *r2chan, char digit)