607df68bd05fdad0f84bec3d65149d2820a3deee
[feed/telephony.git] / net / freeswitch-stable / patches / 400-switch_core_media-fix-stringop-truncation.patch
1 commit e114c6382e68824d4498f62562714860d20804e2
2 Author: Sebastian Kemper <sebastian_ml@gmx.net>
3 Date: Sun Apr 14 19:11:58 2019 +0200
4
5 FS-11783: [core] quiet gcc truncation warning
6
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
11 "memcpy" instead.
12
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 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17
18 This commit follows gcc's recommendation.
19
20 Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
21
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
25 strncpy(q, p, 7);
26 p += 7;
27 q += 7;
28 - strncpy(q, strchr(a_engine->adv_sdp_ip, ':') ? "6 " : "4 ", 2);
29 + memcpy(q, strchr(a_engine->adv_sdp_ip, ':') ? "6 " : "4 ", 2);
30 p +=2;
31 q +=2;
32 strncpy(q, a_engine->adv_sdp_ip, strlen(a_engine->adv_sdp_ip));