Disable -Wformat-truncation and prevent potential string overflows.

GCC 7.3.0 complained about the potential to overflow the fixed size span and
channel names and descriptions. It also flagged potential truncations of the
strings.

The sprintf calls are now changed to snprintf to prevent the potential
overflows, but the warning about truncations are now disabled globally.
This commit is contained in:
Shaun Ruffell 2018-08-09 22:27:40 -05:00
parent 7ecdf370bc
commit 20328895a2
5 changed files with 9 additions and 6 deletions

View File

@ -66,7 +66,7 @@ obj-m += dahdi_echocan_oslec.o
obj-m += ../staging/echo/echo.o
endif
CFLAGS_MODULE += -I$(DAHDI_INCLUDE) -I$(src)
CFLAGS_MODULE += -I$(DAHDI_INCLUDE) -I$(src) -Wno-format-truncation
ifndef HOTPLUG_FIRMWARE
ifneq (,$(filter y m,$(CONFIG_FW_LOADER)))

View File

@ -638,8 +638,8 @@ static int _create_dynamic(struct dahdi_dynamic_span *dds)
DAHDI_CONFIG_HDB3 | DAHDI_CONFIG_CRC4 | DAHDI_CONFIG_NOTOPEN;
d->span.ops = &dynamic_ops;
for (x = 0; x < d->span.channels; x++) {
sprintf(d->chans[x]->name, "DYN/%s/%s/%d",
dds->driver, dds->addr, x+1);
snprintf(d->chans[x]->name, sizeof(d->chans[x]->name),
"DYN/%s/%s/%d", dds->driver, dds->addr, x+1);
d->chans[x]->sigcap = DAHDI_SIG_EM | DAHDI_SIG_CLEAR |
DAHDI_SIG_FXSLS | DAHDI_SIG_FXSKS |
DAHDI_SIG_FXSGS | DAHDI_SIG_FXOLS |

View File

@ -2069,7 +2069,8 @@ static int t1_software_init(struct t1 *wc, enum linemode type)
t4_serial_setup(wc);
set_bit(DAHDI_FLAGBIT_RBS, &wc->span.flags);
for (x = 0; x < wc->span.channels; x++) {
sprintf(wc->chans[x]->name, "%s/%d", wc->span.name, x + 1);
snprintf(wc->chans[x]->name, sizeof(wc->chans[x]->name),
"%s/%d", wc->span.name, x + 1);
t1_chan_set_sigcap(&wc->span, x);
wc->chans[x]->pvt = wc;
wc->chans[x]->chanpos = x + 1;

View File

@ -1805,7 +1805,8 @@ static int t13x_software_init(struct t13x *wc, enum linemode type)
t13x_serial_setup(wc);
set_bit(DAHDI_FLAGBIT_RBS, &wc->span.flags);
for (x = 0; x < wc->span.channels; x++) {
sprintf(wc->chans[x]->name, "%s/%d", wc->span.name, x + 1);
snprintf(wc->chans[x]->name, sizeof(wc->chans[x]->name),
"%s/%d", wc->span.name, x + 1);
t13x_chan_set_sigcap(&wc->span, x);
wc->chans[x]->pvt = wc;
wc->chans[x]->chanpos = x + 1;

View File

@ -2536,7 +2536,8 @@ t43x_init_one_span(struct t43x *wc, struct t43x_span *ts, enum linemode type)
set_bit(DAHDI_FLAGBIT_RBS, &ts->span.flags);
for (x = 0; x < ts->span.channels; x++) {
sprintf(ts->chans[x]->name, "%s/%d", ts->span.name, x + 1);
snprintf(ts->chans[x]->name, sizeof(ts->chans[x]->name),
"%s/%d", ts->span.name, x + 1);
t43x_chan_set_sigcap(&ts->span, x);
ts->chans[x]->pvt = wc;
ts->chans[x]->chanpos = x + 1;