> In file included from /usr/include/string.h:519,
> from core/socket_info.c:34:
> In function 'strncpy',
> inlined from 'fix_hostname' at core/socket_info.c:1741:2:
> Warning: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
> 95 | return __builtin___strncpy_chk (__dest, __src, __len,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 96 | __glibc_objsize (__dest));
> | ~~~~~~~~~~~~~~~~~~~~~~~~~
> core/socket_info.c: In function 'fix_hostname':
> core/socket_info.c:1741:38: note: length computed here
> 1741 | strncpy(address_str->s, tmp, strlen(tmp)+1);
> | ^~~~~~~~~~~
> In file included from /usr/include/string.h:519,
> from core/socket_info.c:34:
> In function 'strncpy',
> inlined from 'build_iface_list' at core/socket_info.c:1554:5:
> Warning: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' output may be truncated copying 63 bytes from a string of length 63 [-Wstringop-truncation]
> 95 | return __builtin___strncpy_chk (__dest, __src, __len,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 96 | __glibc_objsize (__dest));
> | ~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from /usr/include/string.h:519,
> from core/cfg.y:40:
> In function 'strncpy',
> inlined from 'yyparse' at core/cfg.y:708:6:
> Warning: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
> 95 | return __builtin___strncpy_chk (__dest, __src, __len,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 96 | __glibc_objsize (__dest));
> | ~~~~~~~~~~~~~~~~~~~~~~~~~
> core/cfg.tab.c: In function 'yyparse':
> core/cfg.y:708:84: note: length computed here
> 708 | strncpy($$, $1, strlen($1)+1);
> | ^
> In file included from /usr/include/string.h:519,
> from core/cfg.y:40:
> In function 'strncpy',
> inlined from 'yyparse' at core/cfg.y:699:5:
> Warning: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
> 95 | return __builtin___strncpy_chk (__dest, __src, __len,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 96 | __glibc_objsize (__dest));
> | ~~~~~~~~~~~~~~~~~~~~~~~~~
> core/cfg.tab.c: In function 'yyparse':
> core/cfg.y:699:76: note: length computed here
> 699 | strncpy($$, $1, strlen($1)+1);
> | ^
> In file included from /usr/include/string.h:519,
> from core/cfg.y:40:
> In function 'strncpy',
> inlined from 'yyparse' at core/cfg.y:689:6:
> Warning: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
> 95 | return __builtin___strncpy_chk (__dest, __src, __len,
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 96 | __glibc_objsize (__dest));
> | ~~~~~~~~~~~~~~~~~~~~~~~~~
> core/cfg.tab.c: In function 'yyparse':
> core/cfg.y:689:70: note: length computed here
> 689 | strncpy($$, tmp, strlen(tmp)+1);
> |
... | ... |
@@ -682,11 +682,12 @@ listen_id: |
682 | 682 |
LM_CRIT("cfg. parser: bad ip address.\n"); |
683 | 683 |
$$=0; |
684 | 684 |
} else { |
685 |
- $$=pkg_malloc(strlen(tmp)+1); |
|
685 |
+ i_tmp=strlen(tmp)+1; |
|
686 |
+ $$=pkg_malloc(i_tmp); |
|
686 | 687 |
if ($$==0) { |
687 | 688 |
PKG_MEM_CRITICAL; |
688 | 689 |
} else { |
689 |
- strncpy($$, tmp, strlen(tmp)+1); |
|
690 |
+ strncpy($$, tmp, i_tmp); |
|
690 | 691 |
} |
691 | 692 |
} |
692 | 693 |
} |
... | ... |
@@ -696,7 +697,8 @@ listen_id: |
696 | 697 |
if ($$==0) { |
697 | 698 |
PKG_MEM_CRITICAL; |
698 | 699 |
} else { |
699 |
- strncpy($$, $1, strlen($1)+1); |
|
700 |
+ i_tmp=strlen($1)+1; |
|
701 |
+ strncpy($$, $1, i_tmp); |
|
700 | 702 |
} |
701 | 703 |
} |
702 | 704 |
| host_or_if { |
... | ... |
@@ -705,7 +707,8 @@ listen_id: |
705 | 707 |
if ($$==0) { |
706 | 708 |
PKG_MEM_CRITICAL; |
707 | 709 |
} else { |
708 |
- strncpy($$, $1, strlen($1)+1); |
|
710 |
+ i_tmp=strlen($1)+1; |
|
711 |
+ strncpy($$, $1, i_tmp); |
|
709 | 712 |
} |
710 | 713 |
} |
711 | 714 |
} |
... | ... |
@@ -1738,9 +1738,9 @@ static int fix_hostname(str* name, struct ip_addr* address, str* address_str, |
1738 | 1738 |
PKG_MEM_ERROR; |
1739 | 1739 |
goto error; |
1740 | 1740 |
} |
1741 |
- strncpy(address_str->s, tmp, strlen(tmp)+1); |
|
1742 |
- /* set is_ip (1 if name is an ip address, 0 otherwise) */ |
|
1743 | 1741 |
address_str->len=strlen(tmp); |
1742 |
+ strncpy(address_str->s, tmp, address_str->len+1); |
|
1743 |
+ /* set is_ip (1 if name is an ip address, 0 otherwise) */ |
|
1744 | 1744 |
if (sr_auto_aliases && (address_str->len==name->len) && |
1745 | 1745 |
(strncasecmp(address_str->s, name->s, address_str->len)==0)){ |
1746 | 1746 |
*flags|=SI_IS_IP; |