]> git.ipfire.org Git - thirdparty/freeswitch.git/commit
FS-11783: [core] quiet gcc truncation warning
authorSebastian Kemper <sebastian_ml@gmx.net>
Sun, 14 Apr 2019 17:11:58 +0000 (19:11 +0200)
committerSebastian Kemper <sebastian_ml@gmx.net>
Sun, 14 Apr 2019 17:12:03 +0000 (19:12 +0200)
commite114c6382e68824d4498f62562714860d20804e2
tree8fa1c04f43f5828a0fd6504413b867a91086c42a
parenta5858c8b9fa9ca82b6b08602c74c5e9de4166099
FS-11783: [core] quiet gcc truncation warning

With -Wstringop-truncation gcc warns about calls to bounded string
manipulation function "strncpy" that may either truncate the copied
string or leave the destination unchanged. To avoid the warning when the
result is not expected to be NUL-terminated, it is suggested to call
"memcpy" instead.

src/switch_core_media.c: In function 'switch_core_media_patch_sdp':
src/switch_core_media.c:11854:4: error: 'strncpy' output truncated before terminating nul copying 2 bytes from a string of the same length [-Werror=stringop-truncation]
    strncpy(q, strchr(a_engine->adv_sdp_ip, ':') ? "6 " : "4 ", 2);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This commit follows gcc's recommendation.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
src/switch_core_media.c