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: certified-18.9-cert15~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=83c6d73aad257641e0cf50e28fab8edff8b0f26f;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 (cherry picked from commit 0b0f28468403cd34430c934c329c72b5032ba714) --- diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index ad7a8e5e54..9ab7e75919 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -3943,7 +3943,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); @@ -3956,10 +3956,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)