freeswitch/freetdm

Compile failure on Debian 11

Opened this issue · 1 comments

Compiling the current repo code for fretdm with the current repo code for freeswitch fails with the following error:

CC src/libfreetdm_la-ftdm_io.lo
In file included from src/ftdm_io.c:40:
src/ftdm_io.c: In function ‘ftdm_channel_clear_token’:
./src/include/private/ftdm_core.h:134:33: error: ‘strncpy’ output may be truncated copying 127 bytes from a string of length 1279 [-Werror=stringop-truncation]
134 | #define ftdm_copy_string(x,y,z) strncpy(x, y, z - 1)
| ^~~~~~~~~~~~~~~~~~~~
src/ftdm_io.c:1338:5: note: in expansion of macro ‘ftdm_copy_string’
1338 | ftdm_copy_string(ftdmchan->tokens[ftdmchan->token_count], tokens[i], sizeof(ftdmchan->tokens[ftdmchan->token_count]));
| ^~~~~~~~~~~~~~~~

Its really a warning, but the build files treat warnings as errors, so the compile fails. I haven't yet investigated to see what is really going on.

Looking into this it seems like a compiler bug. strncpy if being used to copy an element of an array, where each element is 128 bytes. The error says the source is 1279 bytes, which is one byte less than the size of the entire array. If I modify the code to work past this error the rest of freetdm and mod_freetdm seems to build OK.

make install has another small issue. It installs the actual module but not the ftmod_*.so files. When I manually copy those to /usr/local/freeswitch/mod things seem to be running OK.