1 commit e114c6382e68824d4498f62562714860d20804e2
2 Author: Sebastian Kemper <sebastian_ml@gmx.net>
3 Date: Sun Apr 14 19:11:58 2019 +0200
5 FS-11783: [core] quiet gcc truncation warning
7 With -Wstringop-truncation gcc warns about calls to bounded string
8 manipulation function "strncpy" that may either truncate the copied
9 string or leave the destination unchanged. To avoid the warning when the
10 result is not expected to be NUL-terminated, it is suggested to call
13 src/switch_core_media.c: In function 'switch_core_media_patch_sdp':
14 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]
15 strncpy(q, strchr(a_engine->adv_sdp_ip, ':') ? "6 " : "4 ", 2);
16 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 This commit follows gcc's recommendation.
20 Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
22 --- a/src/switch_core_media.c
23 +++ b/src/switch_core_media.c
24 @@ -11918,7 +11918,7 @@ SWITCH_DECLARE(void) switch_core_media_p
28 - strncpy(q, strchr(a_engine->adv_sdp_ip, ':') ? "6 " : "4 ", 2);
29 + memcpy(q, strchr(a_engine->adv_sdp_ip, ':') ? "6 " : "4 ", 2);
32 strncpy(q, a_engine->adv_sdp_ip, strlen(a_engine->adv_sdp_ip));