local_host_ip_addrs_to_string: fix buffer overflow
parent
564facf33e
commit
15424dfc1c
3
HISTORY
3
HISTORY
|
|
@ -1,4 +1,7 @@
|
|||
|
||||
Version 1.88 2026-09-03
|
||||
* local_host_ip_addrs_to_string: fix buffer overflow
|
||||
|
||||
Version 1.87 2026-07-10
|
||||
* ini_file_readers can refer env variable such as %{env::FASTDFS_IPADDR}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,11 +70,20 @@ const char *local_host_ip_addrs_to_string(char *buff, const int size)
|
|||
|
||||
len = snprintf(buff, size, "local_host_ip_count: %d,",
|
||||
g_local_host_ip_count);
|
||||
if (len >= size)
|
||||
{
|
||||
return buff;
|
||||
}
|
||||
|
||||
pEnd = g_local_host_ip_addrs +
|
||||
IP_ADDRESS_SIZE * g_local_host_ip_count;
|
||||
for (p=g_local_host_ip_addrs; p<pEnd; p+=IP_ADDRESS_SIZE)
|
||||
{
|
||||
len += snprintf(buff + len, size - len, " %s", p);
|
||||
if (len >= size)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return buff;
|
||||
|
|
|
|||
Loading…
Reference in New Issue